0

i am trying to call a web service using simple $.ajax i have been trying to do this for long time but all samples and answers are not working for me and anyone help with this

i am trying to call this url

http://ajaxtest.com.rws2.my-hosting-panel.com/api/values

the result of it is as follows

<ArrayOfusers xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/www.icl.com.sa.Models">
<users>
<id>1</id>
<pass>55</pass>
<uname>john</uname>
<utype>5</utype>
</users>
<users>
<id>2</id>
<pass>0</pass>
<uname>hammad</uname>
<utype>0</utype>
</users>
<users>
<id>3</id>
<pass>7</pass>
<uname>wojeiech</uname>
<utype>7</utype>
</users>
</ArrayOfusers>

can any one please try to call this web service

http://ajaxtest.com.rws2.my-hosting-panel.com/api/values

using simple index.Html file

i tried this million time but no luck

Thank you

4

1 回答 1

0

这归结为跨域限制,可以防止恶意代码在客户端运行。如果您有权访问 Web 服务器和 API 的代码库,则可以将Access-Control-Allow-Origin标头设置为可以执行代码的域,甚至所有值为*.

您也可以调查 JSONP,但如果 API 不支持它,那么您将无法使用数据。

于 2013-06-15T09:29:56.147 回答