RSilva RSilva - 2 months ago 6
jQuery Question

jQuery send POST parameters to PHP

This is how I'm trying to send some data to a php file:

function requestWsList(functionToProcess, me) { = true;

crossDomain: true,
traditional: true,
url: urlWS(),
contentType: "text/xml;charset=UTF-8",
dataType: "html",
type: "POST",
data: {name: 'value', anotherName: 'another value'},
processData: false,
success:function(data) {
functionToProcess(data, me);
} });


When I call this javascript function, the php request is triggered but I always get an empty array in the php variable $_POST.

What am I doing wrong? What do I have to do to read the "name" and "anotherName" variables in PHP?


You set contentType to "text/xml;charset=UTF-8" and you are passing a JavaScript object. Just remove this parameter and it should work.