c# - jsonresult does not come back? -
trying display success message controller?
[httppost] public jsonresult succesmsg() { return json(new { success = true }); }
jquery:
$("#but").click(function () { $.ajax({ url: "/home/succesmsg", type: 'post', data: "", success: function (result) { if (resultjson['success'] == true) { alert('success'); } else { alert('no'); } }, error: function (err) { alert('error') } }); });
add datatype: "json" $.ajax call or use shorthand: $.getjson.
also check controller handles response returns in state http 200 (ok).
for debugging, add complete: function(){alert('complete');} see if request completes or not. debugging tools (add-ons) firefox live http headers , firebug.
Comments
Post a Comment