AJAX submit form to remote URL and extract URL from XML reponse

后端 未结 3 903
夕颜
夕颜 2021-01-26 14:40

I am new to JavaScript and Ajax.

I have a form which posts to remote url and returns a XML response containing some data and a URL. I need to extract the url and redirec

3条回答
  •  感情败类
    2021-01-26 14:55

    Yes, all ajax calls have to be to the same domain as your web page; browsers prohibit you from making ajax calls to remote addresses, with or without jQuery.

    The most common way around this is to use a simple proxy on your end. You call your own proxy—which is on your domain—and the proxy creates a web request to the remote address, and when that returns, the proxy forwards that result to the callback of your ajax request. The proxy is basically just a big dumb middleman.

    You can also get around with by using JSONP, but the remote end has to be set up for this.

    Silverlight can also get you around this, but again, the other end has to be set up for this; they have to have a clientaccesspolicy.xml file in place.

提交回复
热议问题