且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何预解析JSON字符串?

更新时间:2022-05-08 22:18:09

$.getJSON只是以下简称:

$.getJSON is just shorthand for:

$.ajax({
  dataType: "json",
  url: url,
  data: data,
  success: success
});

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

只需使用$ .ajax将dataType更改为"html",然后使用$ .parseJSON解析成功函数中的修改后的JSON数据

Just use $.ajax change dataType to "html" and parse your modified JSON data in the success function with $.parseJSON

注意:由于您似乎正在执行跨域请求,因此必须使用jsonp,请在此处阅读更多信息:

Note: Since it seems you are doing a cross-domain request, you must use jsonp, read more here:

http://learn.jquery.com/ajax/working-with-jsonp /