I am facing a problem i dont know how to describe understandingly in the title, sorry for that. Hopefully it will come clearer in the text.
I already did an ajax post with jquery that worked fine. It was this:
var p1 = $.post(url,{what:"Add",d:dokid,u:seluserid});
p1.done(function(data){
...
Now, to copy that for another side(with a form) with a lots of radio buttons inside, i built the part in the {} as a string (paramlist) and tried to do the same. The resulting string paramlist:
paramlist = {what:"insert",ID:"-1",Name:"",Beschreibung:"",FieldX:"4",FieldY:"4",Roles:"4",FieldZ:"4",FieldN:"4"}
I got the FieldNames and Values by browsing to each radio element.
Now i am calling the .post by:
var p1 = $.post(url,paramlist);
p1.done(function(data){
...
This doesnt seem to work this way, for my php fails recognizing the post parameters.
$what=$_POST['what'];
gives me PHP Notice: Undefined index: what... So obviously i have to transform the string to something else. But how? I am out of search terms right now so i wanted to ask. The jquery api didn't help me. Maybe i am too much a newbie in all this stuff... Any ideas?
What i did to get it to work: removed the {} brackets from the string and put all elements in ". so now paramlist looks like:
paramlist = "what":"insert","ID":"-1","Name":"","Beschreibung":"","FieldX":"4","FieldY":"4","Roles":"4","FieldZ":"4","FieldN":"4"}
then convert the string to an object (with the help of String to object in JS) using eval:
objparamlist=eval('({' + paramlist + '})');
now calling
var p1 = $.post(url,objparamlist);
works.
Thanks to all for your help!