2014-01-21 110 views
2

我从外部域对Web服务进行了AJAX调用,并试图管理XML响应,因为AJAX调用的目标是在Adobe Connect平台上登录并且它作品。但它显示的浏览器控制台下面的错误上:使用XML响应的AJAX JQuery请求

SyntaxError: syntax error 
<?xml version="1.0" encoding="utf-8"?> 

这是AJAX调用的代码:

$.ajax({ 
type : "GET", 
    url : URL, 
    dataType : "jsonp", 
    success : function(service_data) { 
    console.log("OK"); 
    console.log(service_data); 
    }, 
    error : function(msg) { 
    console.log("ERROR"); 
    console.log(JSON.stringify(msg)); 
    } 
}); 

万分感谢。

+1

可以说明你的问题?我的意思是,你的电话有效,但有错误? –

+2

原始'XML'看起来像什么? – JNF

+2

确切地说,它的工作原理是因为它的目标是登录和工作,但它会抛出上面显示的错误。 – AlvaroCasvi

回答

3

你得到的错误是因为你在说你期望一个jsonp并提供了一个xml。

$.ajax({ 
    type : "GET", 
    url : URL, 
    dataType : "xml", 
    success : function(service_data) { 
     console.log("OK"); 
     console.log(service_data); 
    }, 
    error : function(msg) { 
     console.log("ERROR"); 
     console.log(JSON.stringify(msg)); 
    } 
}); 

我会改变具体的数据类型

+2

谢谢LT但你的答案不起作用。 其实XML错误已经解决,但AJAX调用不起作用,情况变得更糟。 – AlvaroCasvi

+0

据推测,在这种情况下,Adobe Connect不会告知用户的浏览器您的网站有权从Adobe Connect中以其用户凭据获取数据。 – Quentin

1

您指定的数据类型为“JSONP”,但你得到的XML作为结果。尝试将数据类型更改为“xml”。更多信息可在http://api.jquery.com/jquery.ajax/中查到,但是相关的位是:

"xml": Returns a XML document that can be processed via jQuery.

"jsonp": Loads in a JSON block using JSONP. Adds an extra "?callback=?" to the end of your URL to specify the callback. Disables caching by appending a query string parameter, "_=[TIMESTAMP]", to the URL unless the cache option is set to true.

3

一个运动课告诉我大约两个候选条件的解决方案:

1 - CORS

2 - 代理脚本。

我会告诉你它是否有效,我会尝试一下。