简体   繁体   English

AJAX POST JSON值

[英]AJAX POST JSON value

I have AJAX POST, the result is JSON: 我有AJAX POST,结果是JSON:

$.ajax({
  type: "POST",
  url: "../../api/test",
  data: JSON.stringify(source),
  contentType: "application/json; charset=utf-8",
  dataType: "json",
  success: function (result) {
    var upload = JSON.stringify(result);
    console.log(upload);
  }
});

The upload result is: 上传结果是:

{"Link":0,"Title":"d","Description":"dada","Keywords":"dad"}

How can I get the value of Title? 我怎样才能获得Title的价值?

不要对结果进行字符串化,只需使用result.Title

As you already have JSON string, It's simple as a pie! 因为你已经有了JSON字符串,它就像馅饼一样简单! All you need to do is to call the property you want from the variable you assigned your result to. 您需要做的就是从您为结果分配的变量中调用所需的属性。

for example: 例如:

var post_response;
$.ajax({
    type: "POST",
    url: "../../api/test",
    data: JSON.stringify(source),
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (result) {
        post_response = JSON.stringify(result);
        console.log("Title: "+post_response.Title);
    }
 });

hope this helps. 希望这可以帮助。

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

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