简体   繁体   中英

What does JSON.stringify data look like in the url

I use JSON.stringify to send jQuery arrays to $_POST data to a PHP file through an .ajax() call. The call works fine and the desired data is returned, but:

If I was going to debug and type in variables manually, what does this data look like in url format?

http://domain.com/ajax.php?foo=1,2&bar=3,4 or something else?

MY SOLUTION: URL is http://domain.com/ajax.php?foo=[1,2]&bar=[3,4]

I would recommend using fiddler and use the Composer therefore you dont have to use separate code for debugging. You can also test what the result would look like by using the console in IE. Generally json.stringy turns your json into a string so it would look like

[1,2,3,4,5,6,7]

You will not be able to post the JSON data as a URL. You are mixing apples and pears. But you could do a few methods.

1) if the JSON is very simple you could actually do a url with the JSON data in it like this http://urdomain/ajax.php?data=[4,5,7] and use $_REQUEST['data'] instead of $_POST['data'] . but this could create more problems than it is worth.

2) best option is to use a browser plugin like this . You can do proper json posts and get the feedback.

3) or if u just want see what is happening you can just look at the browsers NET log in its development panel.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM