jquery - Return multiple views in blank pages through one ActionResult -


i'd appreciate if advise. have 2 views (not partial) , both of them want return in blank pages (target = "_blank") @ time. submit form looks like:

 @using (html.beginform("action1", "controller1",  new { target = "_blank"}) { //model data  <input type="submit" value = "go" id="btn"/> } 

in controller have 2 actionresults:

public actionresult action1(mymodel model) { return view(model); }  public actionresult action2(string year) { viewbag.year = year; return view(); } 

so want call both action1 , action2. action1 accepts model parameter , action2 accepts string taken mymodel well. there way that? tried call action2 through jquery on submit button click, not work want display view in new tab.

thanks in advance!

you should able want this.

it might better create new action returns both views in separate properties in single json object though - making 2 calls.

$("#form").on("submit", function() {     $.ajax({         url: "/controller/action1",         data: $("#form").serialize(),         success: function(response) {             // need response here         }     });      $.ajax({         url: "/controller/action2",         data: { string : $("#form").find("input#your_input_name").val() },         success: function(response) {             // need response here         }     }); } 

edit:

assuming target="_blank" working should able create second hidden form , submit when first 1 submitted.

$("#form").on("submit", function() {     var = $("#form input#input_id_here").val()     $("#form2 input").val(i);     $("#form2").submit();         } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -