Reputation: 423
I'm having a problem with Ajax and POST, as it is not working, sending an empty response, I'm working with text (not Json) data.
Here's the javascript code:
$.ajax({
type: "POST",
url: "php/bddAlumnoElements.php",
data: "methodo=setLecturas,idLectura="+CurrentLecture,
async: true,
success: function(response) {
alert(response);
},
cache: false,
contentType: false,
processData: false
});
return false;
And here's the simple php code I'm using
if(isset($_POST['methodo'])){
echo "blah!";
}
I've also tried the php code like this
if(isset($_POST['methodo'])=="setLecturas"){
$message= "blah!";
}
The response alert is always blank, so I have no idea what's going on, any suggestions?
Upvotes: 1
Views: 343
Reputation: 34914
Change here ,
to &
data: "methodo=setLecturas&idLectura="+CurrentLecture,
Parameter separates by symbol &
not by commas ,
so methodo value becomes unwanted concatination with comma.
Upvotes: 3