Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用JQuery读取XML Get请求_Jquery_Ajax_Get - Fatal编程技术网

使用JQuery读取XML Get请求

使用JQuery读取XML Get请求,jquery,ajax,get,Jquery,Ajax,Get,尝试使用通过GET以XML格式发送数据的API 这是我的密码 $.ajax({ url: 'http://www.ctabustracker.com/bustime/api/v1/getpredictions?key=JcCyb84hceaH4zhFyrxgEvfKj&stpid=1876l', dataType: 'jsonp', success: function( data ) { alert("Success : "+

尝试使用通过GET以XML格式发送数据的API

这是我的密码

   $.ajax({
      url: 'http://www.ctabustracker.com/bustime/api/v1/getpredictions?key=JcCyb84hceaH4zhFyrxgEvfKj&stpid=1876l',
      dataType: 'jsonp',
      success: function( data ) {
          alert("Success : "+data);
      }
    });
我得到这个错误

www.ctabustracker.com/bastime/api/v1/getpredictions?key=JcCyb84hceaH4zhFyrx…1876l&callback=jquery111014777464847266674_1440527282431&_=1440527282432:1未捕获语法错误:意外标记
数据类型应该是xml,如果您知道将获得什么样的信息,请尝试始终向请求提供信息。

如果请求是jsonp,您可能需要在站点的某个位置包含API库,以便它可以在回调时调用AppPeriate javascript函数来处理数据。也可能需要不同的数据类型值,如XML


在网上发布您的密钥时要小心,因为现在其他人可以使用您的帐户。我建议您将其编辑掉并更改密钥,因为它已经被破坏了。除非它是一个测试密钥,并且您可以共享它:)

Um,是否将数据类型更改为xml?
$.ajax({
  url: 'http://www.ctabustracker.com/bustime/api/v1/getpredictions?key=JcCyb84hceaH4zhFyrxgEvfKj&stpid=1876l',
  dataType: 'xml',
  success: function( data ) {
      alert("Success : "+data);
  }
});