简体   繁体   中英

Display text returned from json post call

I have the following javascript:

$.post("/Authenticated/DeletePage/" + PageId);
showStatus("Page deleted...", 10000);

I would like to instead pass showStatus() text that is returned by the $.post() call, rather than hardcoded text. How do I do this?

$.post("/Authenticated/DeletePage/" + PageId, function(data){
   showStatus( data + " deleted...", 10000);
});

and for JSON

$.getJSON("/Authenticated/DeletePage/" + PageId, function(data){
   showStatus( data.pageName + " deleted...", 10000);
});
$.post("/Authenticated/DeletePage/" + PageId, function(JSONdata) {
  showStatus(JSONdata.Name + " deleted...", 10000); //This is just to show you, signature is different
});

See jQuery documentation here: http://api.jquery.com/jQuery.post/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM