【问题标题】:Display text returned from json post call显示从 json post call 返回的文本
【发布时间】:2010-03-15 18:45:19
【问题描述】:

我有以下 javascript:

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

我想传递 $.post() 调用返回的 showStatus() 文本,而不是硬编码文本。我该怎么做?

【问题讨论】:

    标签: asp.net javascript jquery json


    【解决方案1】:
    $.post("/Authenticated/DeletePage/" + PageId, function(data){
       showStatus( data + " deleted...", 10000);
    });
    

    对于 JSON

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

    【讨论】:

      【解决方案2】:
      $.post("/Authenticated/DeletePage/" + PageId, function(JSONdata) {
        showStatus(JSONdata.Name + " deleted...", 10000); //This is just to show you, signature is different
      });
      

      在此处查看 jQuery 文档:http://api.jquery.com/jQuery.post/

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-12-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-12-30
        • 1970-01-01
        • 2018-01-21
        相关资源
        最近更新 更多