Omaruchan Omaruchan - 6 months ago 21
PHP Question

Ajax POST sending back empty response

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?

Answer

Change here , to &

   data: "methodo=setLecturas&idLectura="+CurrentLecture,

Parameter separates by symbol & not by commas , so methodo value becomes unwanted concatination with comma.