Jquery: get xml from the web service
Trying to get xml from the web service:
$.ajax({
type: "GET",
url: 'http://77.65.139.254:10000/_layouts/SPWebService/SPService.asmx/GetFileContentByUrl',
data: { fileUrl: 'Accounts/8b077249-98bb-e011-926f-00155d000e46/EVTemplates/FEFCO0200/FEFCO%200203_3D.JPG' },
dataType: 'text/xml',
success: function (html) {
开发者_运维问答 alert('yes');
}
});
the result is: XML Parsing Error: no element found Location: moz-nullprincipal:{1f083902-dc6e-4e0b-a18e-4aa1ab99ff56} Line Number 1, Column 1:
my request looks like:
Host 77.65.139.254:10000
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2
Accept */*
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip, deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection keep-alive
Origin null
When I insert the link in the browser - it works ok - returns xml. the request (valid) looks like:
GET /_layouts/SPWebService/SPService.asmx/GetFileContentByUrl?fileUrl=Accounts/8b077249-98bb-e011-926f-00155d000e46/EVTemplates/FEFCO0200/FEFCO%200203_3D.JPG HTTP/1.1
Host: 77.65.139.254:10000
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Connection: keep-alive
What is wrong with my jquery get?
You'll need to proxy the XML request. Make the Cross-domain from backend and echo it locally.
This article might help: http://msdn.microsoft.com/en-us/magazine/cc163499.aspx or this: http://www.ajaxprojects.com/ajax/tutorialdetails.php?itemid=409
精彩评论