javascript - Jquery .post(url,params) - how to use this if params is a string? -


i facing problem dont know how describe understandingly in title, sorry that. come clearer in text.

i did ajax post jquery worked fine. this:

var p1 = $.post(url,{what:"add",d:dokid,u:seluserid}); p1.done(function(data){ ... 

now, copy side(with form) lots of radio buttons inside, built part in {} string (paramlist) , tried same. resulting string paramlist:

paramlist = {what:"insert",id:"-1",name:"",beschreibung:"",fieldx:"4",fieldy:"4",roles:"4",fieldz:"4",fieldn:"4"} 

i got fieldnames , values browsing each radio element.

now calling .post by:

var p1 = $.post(url,paramlist); p1.done(function(data){ ... 

this doesnt seem work way, php fails recognizing post parameters.

$what=$_post['what']; 

gives me php notice: undefined index: what... have transform string else. how? out of search terms right wanted ask. jquery api didn't me. maybe newbie in stuff... ideas?

what did work: removed {} brackets string , put elements in ". paramlist looks like:

paramlist = "what":"insert","id":"-1","name":"","beschreibung":"","fieldx":"4","fieldy":"4","roles":"4","fieldz":"4","fieldn":"4"} 

then convert string object (with of string object in js) using eval:

 objparamlist=eval('({' + paramlist + '})'); 

now calling

var p1 = $.post(url,objparamlist); 

works.

thanks help!

this how them.. ..a little extrapolated, easier read.

$.ajax({     url: "/ajax/url.php",     type: "post",     data: {         data: json.stringify(paramlist)     },     success: function..... 

Comments