Advertisement
Guest User

Untitled

a guest
Apr 24th, 2014
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. var sample1 = "aaa";
  2. var sample2 = "bbb";
  3.  
  4. $.ajax({
  5.  
  6. url: "Action/Controller",
  7. data: $("#form123").serialize(),
  8. cache: true,
  9. type: "POST",
  10. dataType: 'html',
  11. success: function (data) {
  12. $('#form123').html(data)};
  13.  
  14. });
  15.  
  16. data: {
  17. formData: $("#form123").serialize(),
  18. sample1: sample1,
  19. sampleTwo: sample2
  20. }
  21.  
  22. var formData = $("#form123").serialize() + '&' + sample1 + '&' + sample2;
  23. $.ajax({
  24. ...
  25. data: formData,
  26. ...
  27. });
  28.  
  29. $.ajax({
  30. url: "Action/Controller/" + sample1 + "/" + sample2,
  31. data: $("#form123").serialize(),
  32. cache: true,
  33. type: "POST",
  34. dataType: 'html',
  35. success: function (data) {
  36. $('#form123').html(data)};
  37.  
  38. });
  39.  
  40. @using(Ajax.BeginForm("Action", "Controller", new {@param1 = "aaa", @param2 = "bbb"}, new AjaxOptions(){HttpMethod = "Post", UpdateTargetId = "#section1"})){
  41. <div id="#section1">
  42.  
  43. ..... put your form controls here . . .
  44.  
  45. </div>
  46. }
  47.  
  48. public PartialViewResult Action(string param1, string param2, ViewModel model)
  49.  
  50. <input type="hidden" id="var1" name="var1" value="@sample1" />
  51.  
  52. <input type="hidden" id="var2" name="var2" value="" />
  53.  
  54. $('#var2').val(var2); //before sending your form of course!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement