code_junkie

Refresh table info using jQuery and ASP.NET MVC

Nov 12th, 2011
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. {
  2. result: 'SUCCESS',
  3. description: 'Email Added.'
  4. }
  5.  
  6. //This function abstracts away the strangeness in dealing with the eval method and returning JSON objects
  7. //If there is a better way, let me know
  8. function ParseJSON(jsonText) {
  9. var ret = null;
  10. eval('ret = '+jsonText);
  11. return ret;
  12. }
  13.  
  14. var ret = ParseJSON(response.value);;
  15.  
  16. if(ret.result == 'SUCCESS') {
  17. //Add a new TR to your table here
  18. } else {
  19. //Display the error message here
  20. // alert(ret.description);
  21. }
  22.  
  23. $("#ajaxLoading").show();
  24.  
  25. $.ajax({
  26. type: "POST",
  27. url: "/Hoofdgroepen/Add",
  28. data: "nummer=" + nummer + "&omschr=" + omschr,
  29. dataType: "html",
  30. success: function(result) {
  31. //alert(result);
  32. $("tr:last").after(result);
  33. $("#ajaxLoading").hide();
  34. $("#hfdgrpForm").resetForm();
  35. }
  36. });
Add Comment
Please, Sign In to add comment