开发者

Missing ; before statement when I check response in Firebug?

var on_show_info_agile = function() {
    alert("aa");
    request_meta_info = $.ajax({
        url: search_metadata + current_doc_info.id,
        type: 'GET',
        async: false,
        dataType: "jsonp",
        success: on_get_metadata,
        error: on_get_metadata_error
 开发者_JAVA百科   });   
};

How can I resolve this issue? I tried changing dataType to "script", I am getting the same error in firebug;

missing ; before statement

<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader"><int name="status">0</int><int name="T">3</int><lst name="params"><str name="q">83779616</str><str name="callback">jsonp1308182704622</str></lst></lst><result name="response" numFound="1" start="0"><doc><str name="number">2716837</str><str name="itle">Wire</str><str name="name">Designated </str><str name="name">S.</str><date name="">2009-03-03T08:00:00Z</date><str name="claims">8</str><str name="id">810414</str><str name="name">D.</str><date name="date">2010-08-24T07:00:00Z</date><str name="_id">83616</str><str name="name">Non Provisional</str><date name="_date">2008-03T08:00:00Z</date><arr name=id"><str>3260</str><str>290</str><str>2510</str></arr><str name="_number">08CA</str><date name="te">201-03T08:00:00Z</date><str name="e">M</str><str name="">Application</str><str name="ry_code">CA</str><str name="ame">Canada</str><str name="_claims">74</str><arr name="inventors"><str>Kd D.</str><str>G</str><str>Pi</str></arr><str name="key">83</str><arr name="owne"><str></str></arr><arr name="tors"><str>d D.</str><str>G</str><str>Pai</str></arr><arr name="ers"><str></str></arr><str name="url"/></doc></result>

</response>

Above is the XML that I am getting but with the error. Any suggestions will be appreciated.


You're requesting XML, but telling jQuery that it's JSON with Padding. It throws a syntax error because it is not valid JavaScript code and therefore can't be parsed as JSONP.

It's obvious that you're trying to obtain data from a different domain, which is why it doesn't work when you switch to XML. For cross-domain requests, you need to look into CORS, XMLHttpRequest Level 2 and IE's XDomainRequest. For support in older browsers, I'm afraid you're out of luck unless you can modify the resource to output valid JSON with padding.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜