send request as jsonp, interpret response as text, using jQuery 1.5

妖精的绣舞 提交于 2019-12-03 15:44:16

What you're trying to achieve won't work: jsonp can only be used if and when the server properly embed the response in a javascript function call.

Even though the server does send the file to the browser, you won't be able to access it because of security limitations: all you can do is execute said data as a script (with a script tag) or use it as a stylesheet (using a link tag) but you'll never, ever, be able to inspect the response in raw text if it's from another domain.

I suppose you tried to get the data as xml directly and that it failed (meaning the site does not support CORS). If you cannot change code server-side, then you only have two alternatives:

  1. Create a proxy on your own server that would tunnel the response (your server-side script makes the actual request and sends it to the browser): same-domain will then apply from the client's point of view and you'll be able to request data as XML,
  2. Use flash to bypass browser's security (you can use flXHR but it seems to be a little dated now).
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!