Reputation: 73
I am completely new to Ajax (Jquery POST), and I wrote this thing to try to "talk" to a .php file:
function send(d){
$.post("http://somesite.net/read.php",{data:d})
.done(function(data){
document.getElementById('res').innerHTML=data;
});
}
Read.php:
$d=$_POST["d"];
echo $d;
So, it does return stuff, but it seems like it returns the entire file. It is very likely I am doing something incredibly wrong. I would like to know what it is.
Upvotes: 0
Views: 56
Reputation: 3744
$.post("http://somesite.net/read.php",{data:d})
You have given a full url, but for the security purpose this is NOT ALLOWED
use $.post("./read.php",{data:d})
instead of $.post("http://somesite.net/read.php",{data:d})
Upvotes: 1
Reputation: 1136
It should be:
$d=$_POST["data"];
echo $d;
See this line:
{data:d}
You are sending variable data with a value d. So in your backend, you should request for variable name.
Upvotes: 2