简体   繁体   English

显示从JSON帖子调用返回的文本

[英]Display text returned from json post call

I have the following javascript: 我有以下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. 我想改为传递由$ .post()调用返回的showStatus()文本,而不是硬编码的文本。 How do I do this? 我该怎么做呢?

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

and for JSON 和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/ 请在此处查看jQuery文档: http : //api.jquery.com/jQuery.post/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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