i am using serialize()
Some Event trigger(assume click)
var querydata= a=1&b=2&c=3 //jquery printing
$.ajax({
url: "script",
data: querydata,
method: "POST",
dataType: "text",
success: function(data) {
$("#counts").html(data);
}
});
in php do i just use the regular post method
a=htmlspecialchars($_POST["a"]); b=htmlspecialchars($_POST["b"]); and so on
or do i need to use jquery to get the string to variables and then send to data as a object array
if jquery is also an option could you tell me how i would do that im fairly new to jquery and i really want to learn it
var_dump($_POST)would show you what php's receiving. and note that jquery will happily accept an array/object fordataand do the necessary querystring transforms for you. you DON'T have to manually build the string yourself.data: {"a":1,"b":2,....}works just fine.dataparameter, which you're inserting into your page already anyways.