php array in url from json

Posted by mcgrailm on Stack Overflow See other posts from Stack Overflow or by mcgrailm
Published on 2010-04-12T14:38:01Z Indexed on 2010/04/12 14:43 UTC
Read the original article Hit count: 431

Filed under:
|
|
|
|

Here is what I want to do:

I have some json like this

  var foo = {
   format:"json",
   type:"test",
   id:"26443"
  };

and I awant to put that in a url like this

 'http://example.com/a:3:{s:6:"format";s:4:"json";s:4:"type";s:5:"test";s:2:"id";s:5:"26443";}'

which I will then put into ajax call but everything I have tried results in error 501 BAD URI could someone tell me how to do this

I've tried this

 function js_array_to_php_array(a) {
  var a_php = "";
  var total = 3;

  for (var key in a){
   total;
   a_php = a_php + "s:" + String(key).length  + ":\""  + String(key) + "\";s:" + String(a[key]).length  +  ":\"" + String(a[key])  + "\";";
  }
  a_php = "a:" + total +":{" + a_php + "}";
  return a_php;
 }

which I found out on the web but had to mod to get to run but still no luck

© Stack Overflow or respective owner

Related posts about JSON

Related posts about jQuery