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.
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?
How do I enable cross-domain AJAX calls without the originating server having PHP/CGI enabled?
Any feedback/advice would be greatly appreciated.
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" ....>
and have send.php do a header redirect back to the original site after sending:
header("Location: http://www.serverwithoutphp.com/thanks.htm");
die();
On applications supporting it, you can do it with JSONP
Related
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
request content on another domain/server
am trying to make an ajax request to a php code using xmlHTTPrequest, my application works on tomcat server, and am trying to make a request to PHP code in WAMP server (different server with request URL localhost), my PHP code simply receives a parameter,makes a query in a PostgreSQL database,and returns the result in XML format...my main problem is how to send the ajax request to that PHP code from my application that run on Tomcat with URL localhost:8080... any help will be appreciated, thanks
You should access the PHP script from within your application running on the tomcat server. Not from the client side.
check the following link.
adding header header('Access-Control-Allow-Origin: *');
to the PHP code might solve the problem
you can't make an ajax request to a different domain. that's not allowed for security reasons. if both of your servers run on the same domain though there's no problem using ajax to request information.
using an javascript API like jQuery will make this a lot easier. here's how to perform ajax requests with jQuery
I'm using PHP, for web designing.
before loading the page I want to check firebug in installed are not in browser, Is there any function in php else how to find firebug plugins is installed or not.
You can't do this. However, it's possible with JavaScript:
if (window.console && window.console.firebug) {
/* firebug found! */
}
PHP is on server side, I don't think there's method to find the client side plugin info. Unless, you can control the browser, then you can detect and put the info in HTTP request, so that server can know.
I don't think that there are any possibilities to check with PHP, but with JavaScript: finding out if console is available
Not on a normal http request, however you can check it with javascript on the client, then make an ajax to the server with the response and act acording to it. detect firebug with javascript
Since firebug does not expose itself via a request header its presence or absence in unknown to the web server.
You would need some client side js in the page that checks for and then sends the result of window.console.firebug to a php script which then associates that result in a session variable.
i want to get data from other sites using javascript executed from my website.
The PHPJS website has some nice conversions of PHP functions into Javascript.
In general, unless they expose the data with JSON-P, you can't thanks to the security considerations imposed by the same origin policy.
Recent browsers support a permissions system where a remote site can allow JavaScript running on a remote site to make a request. Flash provides a similar system, so can act as an intermediary. Both of these require the cooperation of the remote site.
The usual work around is to use a proxy service, either running on your own system (so JS makes the request to the same server, which fetches the data from the remote site) or a third-party service like YQL.
Javascript is limited by the same-domain security policy. The only way to get data from other sites is to use JSONP or build a proxy on your own host that lets you curl content from other sites.
Use jQuery:
$.post( 'http://some.website.com/file.js', function(result){
alert(result);
});
You may not fetch anything but JavaScript or JSON.
Or try this answer: How do I send a cross-domain POST request via JavaScript?
It has to be done server side - send an ajax request, run the PHP you want, and check the responseText property to see the results.
That really depends on what you mean by "data". Try using AJAX if its just for simple requests.
I've got two servers running jsp and php. I'd like the PHP page to call the JSP page for getting an output. I tried using simple Ajax and Jquery-Ajax, it doesn't seem to work. Why?
you can't use ajax cross domains due to security restrictions. you could send the data to an php-script on your domain and send the post-request from there with a function like this
AJAX cannot request pages from sites that reside in different servers. This will make it a cross-side scripting attack. Hence, you have to go only through your server side code. For PHP you can use curl to get information from other pages. You can now use the same ajax script and link it to the php page containing curl. Documentation of curl can be found if you give a google over it.
I was wondering how I could see what variables my flash sends to my PHP script. Is that possible? Maybe an extension or something else? I don't know if my flash is sending any variables.
My problem is that I have a flash which I can't change and the flash has a form. In that form the variables are sent to a PHP script. We had to move that script and now I made a redirect script which was working great with the webform(html_ but not with the flash form. Does anyone have some ideas about how I could fix this?
As as using Firebug for viewing HTTP requests inside Firefox, also check out Fiddler, a proxy app which sits between your browser and the Internet and shows you detailed information about every HTTP request.
Use the firebug plugin with FireFox