For example,
I have an ajax
request from the page http://www.abc.com/xyz/1
to the function controlling ajax
.
Is there any way except sending it through the parameters so that I could know that in the function I can fetch http://www.abc.com/xyz/1
and realise that the ajax request came from here?
The url parameter is a string containing the URL you want to reach with the Ajax call, while settings is an object literal containing the configuration for the Ajax request. In its first form, this function performs an Ajax request using the url parameter and the options specified in settings .
$. ajax({ type: 'POST', url: 'page. php', data: stuff, success: function( data ) { }, error: function(xhr, status, error) { // check status && error }, dataType: 'text' });
ajax({ type: "POST", url: 'test. php', data: {"type":"check"}, success: function(response){ alert(response); } }); There can obviously be more key-val pairs in data. In this case your alert should read: "The type you posted is check".
If the server wants to know from which page, or the server's location, then you can use this in the end, if PHP:
die($_SERVER["HTTP_HOST"] . $_SERVER["HTTP_REFERER"]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With