Send a XML request using jQuery -
i want communicate ups api via jquery , ajax. xml seems formed, works fine in similar asp script. figured skip asp script , communicate directly ups via jquery. however, when send request, response comes as:
method: options
status: load cancelled
i assume missed kind of option in ajax request tells send xml ups server.
$(document).ready(function() { $.ajax({ type: "post", url: "https://wwwcie.ups.com/ups.app/xml/xav", data: "<?xml version=1.0?>" + " <accessrequest xml:lang='en-us'>" + " <accesslicensenumber>licensenumber</accesslicensenumber>" + " <userid>user</userid>" + " <password>pass</password>" + " </accessrequest>" + " <?xml version=1.0?>" + " <addressvalidationrequest xml:lang='en-us'>" + " <request>" + " <transactionreference>" + " <customercontext>addressvalidationrequest</customercontext>" + " <xpciversion>1.0</xpciversion>" + " </transactionreference>" + " <requestaction>xav</requestaction>" + " <requestoption>3</requestoption>" + " </request>" + " <addresskeyformat>" + " <addressline>1234 n. main street</addressline>" + " <politicaldivision2>los angeles</politicaldivision2>" + " <politicaldivision1>ca</politicaldivision1>" + " <postcodeprimarylow>90210</postcodeprimarylow>" + " <countrycode>us</countrycode>" + " </addresskeyformat>" + " </addressvalidationrequest>", contenttype: "text/xml", datatype: "xml", cache: false, error: function() { alert("no data found."); }, success: function(xml) { alert("it works"); alert($(xml).find("project")[0].attr("id")); } }); });
it seems making cross domain call.
need use jsonp cross domain calls. refer ajax
crossdomain (default: false same-domain requests, true cross-domain requests) type: boolean if wish force crossdomain request (such jsonp) on same domain, set value of crossdomain true. allows, example, server-side redirection domain. (version added: 1.5)
Comments
Post a Comment