View Single Post
Old 07-18-2012, 10:57 PM   PM User | #4
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,455
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
here is one way:

Code:
function ob2url(ob){
  var buffer=[], param, enc=encodeURIComponent;
  for(param in ob){if(ob.hasOwnProperty(param)&& !ob[param].call){
    buffer[buffer.length]= enc(param)+"="+enc(ob[param]);
  }}//next own
 return buffer.join("&");
}



//myData= <? echo json_encode($data); ?> ;
myData={"task": "getuniqueid", "id": 3}; //for demo

$.ajax({
url: '../resources/ajax.api.php?'+ob2url(myData),
success: function(data)
{
var task = data.task;
var id = data.id; 

}
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%
rnd me is offline   Reply With Quote