使用jQuery和AJAX跨域PHP电话 [英] Cross-domain PHP calls using jQuery and AJAX

查看:161
本文介绍了使用jQuery和AJAX跨域PHP电话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在哪里我使用的服务器未配置为允许PHP或CGI一个问题,我需要发送使用从表单变量收到邮件此服务器上的主人,就像一个普通的查询/反馈表。

I have a problem where the server I'm using is not configured to allow PHP or CGI and I need to send a mail using variables received from a form on this server to the owner, like a general enquiry/feedback form.

有谁知道我可以调用配置为使用PHP,然后用传递给它的变量执行电子邮件()函数,服务器上的其他领域简单的PHP文件从我的非PHP / CGI服务器?

Does anyone know how I can call a simple PHP file on another domain configured to use PHP and then execute the mail() function on that server with variables passed to it from my non-PHP/CGI server?

如何启用跨域没有原始服务器具有支持PHP / CGI AJAX调用?

How do I enable cross-domain AJAX calls without the originating server having PHP/CGI enabled?

任何意见/建议将不胜AP preciated。

Any feedback/advice would be greatly appreciated.

推荐答案

这也许在某种程度上是可行的使用JSONP,但你并不需要使用Javascript这一点。在更容易的解决办法是将发送PHP脚本在远程服务器上,如:

It's probably somehow doable using JSONP, but you don't need Javascript for this. The much easier solution would be to place the sending PHP script on the remote server, e.g.

 www.serverwithphp.com/send.php

,然后直接点反馈表到脚本:

and then to point the feedback form directly to that script:

 <form action="http://www.serverwithphp.com/send.php" ....>

和具有 send.php 不要发送后一个头重定向回原来的网站:

and have send.php do a header redirect back to the original site after sending:

 header("Location: http://www.serverwithoutphp.com/thanks.htm");
 die();

这篇关于使用jQuery和AJAX跨域PHP电话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆