简体   繁体   中英

JQuery ajax request data

There is a ajax request like this:

var user = {
    username: 'levi',
    password: '111111'
};
$.ajax({
    url: url,
    method: "GET",
    data: {user: user},
    success: function(data) {}
 });

the url is ?user%5Busername%5D=levi1&user%5Bpassword%5D=11111"

but what I need is ?user.username=levi1&user.password=11111"

The url itself replaces special characters.

Read through the link http://www.blooberry.com/indexdot/html/topics/urlencoding.htm

Also you may encode the url using encodeURIComponent();

Try the following syntax to allow for dots in the object's keys:

var user = {'user.username': 'levi', 'user.password': '111111'};
$.ajax({
    url: url,
    method: "GET",
    data: user,
    success: function(data) {}
 });

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