简体   繁体   English

跨域Ajax,相同的服务器但不同的端口?

[英]Cross Domain Ajax, same server but different port?

I am new to AJAX and trying to learn. 我是AJAX的新手并且正在努力学习。 I have setup a Java servlet running on port 8983 which returns XML search results from a database when queried. 我已经设置了一个在端口8983上运行的Java servlet,它在查询时从数据库返回XML搜索结果。 I am also running a wamp server on port 80 and trying to get these search results to show up on the page. 我还在端口80上运行一个wamp服务器,并尝试将这些搜索结果显示在页面上。 I assuming I am encountering this cross domain ajax call problem even though it's the same host, because I'm running these services on 2 separate ports? 我假设我遇到这个跨域ajax调用问题,即使它是相同的主机,因为我在2个独立的端口上运行这些服务?

I heard the solution is to use jsonp to wrap the response form the servlet in a function. 我听说解决方案是使用jsonp将响应形式包装在函数中的servlet中。 The problem is, I don't think I can do this since this servlet is Apache Solr and I've just configured it and am running it out of the box. 问题是,我不认为我可以这样做,因为这个servlet是Apache Solr,我刚刚配置它并且开箱即用。

Any suggestions? 有什么建议么?

根据http://xplus3.net/2010/09/21/solr-and-jsonp/ ,您可以让SOLR接受JSONP请求

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM