简体   繁体   English

从Api获取json数据

[英]Get json data from Api

i am using the third party api for getting the Address on the basis of postcode . 我正在使用第三方api根据邮政编码获取地址。 it returns the json data . 它返回json数据。 below is the api that i am calling but i am not sharing the datakey that i am using . 下面是我正在调用的api,但我没有共享我正在使用的datakey。

i am accessing this in jquery not using any server side scripting languages . 我不使用任何服务器端脚本语言在jquery中访问此。

 $.getJSON("http://www.simplylookupadmin.co.uk/JSONservice/JSONSearchForAddress.aspx?datakey=data key &postcode=CM129BY&callback=?",           function () {
            alert("aaa");

                  });

also using the other code like 也使用其他代码,例如

//          jQuery.ajax({
//              type: 'GET',
//              url: 'http://www.simplylookupadmin.co.uk/JSONservice/JSONSearchForAddress.aspx?datakey=data key&postcode=CM129BY?jsoncallback=?',
//              dataType: 'json',
//              success: function (data) {
//                  alert('success');
//              }
//          });

but i am getting the error 但我得到了错误

Error: invalid label
Source File: http://www.simplylookupadmin.co.uk/JSONservice/JSONSearchForAddress.aspx?datakey=datakey&postcode=CM129BY&callback=jQuery17209661092291729644_1335505434728&_=1335505437637
Line: 2, Column: 2
Source Code:
  "found":"1", 

please advice its very urgent 请告知它非常紧急

Thanks naveen Kumar GUpta. 感谢naveen Kumar GUpta。

I think you may be missing any Quotes.Please check it once again. 我认为您可能缺少任何报价。请再次检查。

I think the postcode you are searching is not found in the Database. 我认为您正在搜索的邮政编码未在数据库中找到。

I got it. 我知道了。 It is the JSON result string is invalid as JSON, open the URL http://www.simplylookupadmin.co.uk/JSONservice/JSONSearchForAddress.aspx?datakey=data key &postcode=CM129BY&callback=? 是JSON结果字符串作为JSON无效,请打开URL http://www.simplylookupadmin.co.uk/JSONservice/JSONSearchForAddress.aspx?datakey=data key&postcode = CM129BY&callback =? with web browser I got the content: 使用网络浏览器,我得到的内容是:

{
  "found":"1",
  "credits_display_text":"Cannot find FULL PAF license(credits or users)",
  "accountadminpage":"https://www.simplylookupadmin.co.uk/WebAccountLogin.aspx?doid=1&coid=30&Pay=yes",
  "errormessage":"Search denied! Cannot find FULL PAF license(credits or users)",
  "maxresults":"0",
  "recordcount":"0",
"records"]}

At the end of it, "]" is not needed. 最后,不需要“]”。

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

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