开发者

return xml through Jquery $.ajax but through cross domain

I have an application X that uses another application Y in certain cases.

X in on an Apache server, Y is on a Tomcat server.

I have a button in html file in Y which calls a JavaScript function StopApp(). This function StopApp() calls the script "StopApp.php" which is on X.

So what I did inside StopApp() is something like

function StopApp()
{
//USING JQUERY $.ajax
  $.ajax({
    type: "GET",
        url: pathofX + "StopApp.php",
        cache: false,
        data:"blablabla",
        dataType: "xml",

      success: function(xml)
    {

    }
  });
}

OK so the thing is "StopApp.php" returns an XML document, and I would like to get the values of the XML tag inside the success field, but I am not being able to do that. I know it has to do with cross domain because it's开发者_JAVA技巧 2 different servers, but I don't know how to resolve it.


If you are allowed to change StopApp.php (alternatively, you can create a wrapper that calls functions from StopApp.php) and put all the logic in this file(I mean all actions the function success is supposed to do), you can use technique from the article Ajax & PHP without using the XmlHttpRequest Object. Briefly, you need to create a SCRIPT element with http:://Y/StopApp.php source and append it to document body. It's a pure JS solution, but maybe you'll find jquery plug-in that can do the same.


Cross-domain calls are forbidden, you cannot circumvent this any portable way.

Btw, accept some of your older questions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜