2013-10-10 63 views
1

我试图通过jQuery ajax制作一个跨域请求。但是回调函数不能被触发。jquery jsonp请求回调函数没有触发

以下是js代码。

$.ajax({ 
     type: "get", 
     url: "http://xx.cc/yy/zz.qq?ppp=xx&callback=?", 
     dataType: "jsonp", 
     success: function (result) {     
      $("#frequentlyBoughtContainer").html(result); 
      InitPageData();     
     } 
    }); 

并且服务器侧响应是这样的:

Request URL:http://qaps.cc/qaps/BehaviorData!GetPageSlots.qs?ProductId=24875&PersonalizationMode=C&callback=jQuery171016283606179058552_1381370760591&_=1381370766821 

Status Code:200 OK 

Request Headers: 

Accept:*/* 

Accept-Encoding:gzip,deflate,sdch 

Accept-Language:en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4 

Cache-Control:no-cache 

Connection:keep-alive 

Pragma:no-cache 


Query String Parameters: 

ProductId:24875 

PersonalizationMode:C 

callback:jQuery171016283606179058552_1381370760591 
_:1381370766821 

Response Headers: 

Cache-Control:private 

Content-Length:10144 

Content-Type:text/javascript; charset=utf-8 

这是响应内容:

jQuery1710162836061790585521381370760591(” ...... \ u003cli \ u003e \ r \ n \ u003cp class = \“showImg \”\ u003e \ r \ n .....“)

我让一个失误?

+0

在控制台中是否出现错误? –

回答

-1

请试一试,看是否有在控制台中的错误。这可能是返回数据中的问题。

$.ajax({ 
    type: "get", 
    url: "http://xx.cc/yy/zz.qq?ppp=xx&callback=?", 
    dataType: "jsonp", 
    success: function (result) {     
     console.log(result);    
    } 
}); 
+0

非常感谢,返回的数据有错误。 – geo