本文介绍了jQuery发布到外部php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想发布到外部php文件并获取结果.它是我在线托管在服务器中的php.我想要由ajax在我的本地主机帖子中添加静态页面,并将html加载到div中.但是我无法做到这一点.
I want to post to an external php file and get the result. It a php that i have hosted in my server online. I want the static page in my localhost post by ajax and load the html in a div. But I'm not able to do this.
$.post("www.site/index.php", { font: "panchami", input: "hi" } );这有什么问题吗?
推荐答案JavaScript不允许跨域请求
您可以做的是服务器上的一个PHP文件,该文件读取另一个网站的内容:
What you can do is a PHP file on your server that reads the contents of the other site:
<?php echo file_get_contents($_REQUEST['url']); ?>然后向您的文件发出请求,如下所示:
Then make requests to your file, like so:
$.post("proxy.php?url=external_url", ...);更多推荐
jQuery发布到外部php
发布评论