简体   繁体   中英

When using GET in php for data generated with jQuery's $.param(data), there are %5B and %5D

I have JSON data called rowdata that I use in an ajax call. If I use:

JSON.stringify(rowdata)

it looks like like the following:

{"Description":"qwerty","Code":"12345","Size":"11","Colour":"green"}

I do send it to php and use a GET statement (Joomla's

JRequest::getVar("Description",  "", "", "")

statement) to get the elements of rowdata but I cannot succeed.

If I look at the ajax data that has been send I do have the following:

rowdata%5BDescription%5D=qwerty

etc. after applying:

$.param(data)

I have used many version instead of "Description", but to no avail. I tried to get rowdata on its own and access its elements, but no success. I cannot find out what the %5B and %5D means, searching for that is problematic with the % sign. Anyone who can help to get the values of Description, Code, etc. in php?

You are sending JSON, but trying to parse it as application/x-www-form-urlencoded data.

Don't convert the object to JSON.

$.get('example.php', {"Description":"qwerty","Code":"12345","Size":"11","Colour":"green"});

I believe %5B is [ and %5D is ] . Your URL is encoding special characters. It's called URL encoding .

如果要使用get推送数据,请不要使用JSON ...否则它将被编码为JSON格式,并且您将获得这些实体。

$.get('target.php', {"Description":"qwerty","Code":"12345","Size":"11","Colour":"green"});

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