Skip to content

@samshull /gist:835173
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
function encode_users(data) {
var string = '';
$.each(data, function(index, info) {
string += '&users[' + index + '][onlineid]=' + encodeURIComponent(info.onlineid);
string += '&users[' + index + '][comment]=' + encodeURIComponent(info.comment);
});
return string;
}
$.ajax({
type: "POST",
url: "sync.php",
data: encode_users(users)
})
/*
encode_users([{onlineid: 1, comment: 1}, {onlineid: 2, comment: 2}])
returns :
"&users[0][onlineid]=1&users[0][comment]=1&users[1][onlineid]=2&users[1][comment]=2"
Which can be parsed by:
<?php
print_r($_POST['users']);
?>
Into:
Array
(
[users] => Array
(
[0] => Array
(
[onlineid] => 1
[comment] => 1
)
[1] => Array
(
[onlineid] => 2
[comment] => 2
)
)
)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.