胖鸭 2010-10-05 20:47
浏览 43

XML跨端口在同一台服务器上?

hey all, i have an apache server on port 8080 and apache tomcat on 8181.

i want to call a command in apache from tomcat. this command is a php script found on the apache server port 8080.

i use jquery inside a javascript function on tomcat server, using $.ajax. sthg like:


function fct()
{
$.ajax({
    type: "GET",
        url: pathofApache8080 + "script.php",
        cache: false,
        data:"blablabla",
      dataType: "xml",

  success: function(xml)
{
}

}); }

now currently this works except that the xml that the php file should return is not being returned. i thought it considers it as cross domain issue, i installed jquery plugin for cross domain found at this site: http://github.com/jamespadolsey/jQuery-Plugins/blob/master/cross-domain-ajax/jquery.xdomainajax.js

this plugin works fine if i try it for lets say google.com, or any other site... it just doesnt work when i call from my apache tomact to apache which are on same server different ports... is there anything as cross port issue? or is it a configuration in php.ini file that i should modify?

any suggestions? thanks a lot:)

  • 写回答

1条回答 默认 最新

  • weixin_33726318 2010-10-07 01:00
    关注

    I tried this, sometimes it works, sometimes not. Got no idea why, sorry.

    But: The plugin you found there doesn't perform magic. It will fetch the external ressource using jsonp. The adress will be sended to a proxy(query.yahooapis.com) , which requests the URL and sends it back.

    So why don't you create your own proxy. All you need is a PHP-Skript on host:8080 which receives the adress host:8181, requests the adress and print's the response. If you do this, you dont have to workaround with jsonp, because it's no same-origin-issue and security also should'nt be a problem, as long you have control over the requested ressource.

    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序