i have this code for sending data
var test={imagename:"apple.jpg",x:"13",y:"33"};
$.ajax({
type: "POST",
url: "some.php",
data: test,
success: function(response){
console.log(response);
}
});
but now i want to send multiple data to php.My php side code is like this
print $_POST['imagename'];
i think of an approach like this
var test={imagename:"apple.jpg|hen.jpg",x:"13|44",y:"33|22"};
and on php getting $_POST['imagename'] then split it according to | but i am not liking semantic approach of it.
1-Does any one know better solution?
2-Please provide both javascript,jquery and php code for answer.
3-One final question is this notation called json var test={imagename:"apple.jpg",x:"13",y:"33"};
Thanks
An array is the most meaningful solution here – something like this in JavaScript:
Send as:
and in PHP you can get them like:
Lastly,
var test={imagename:"apple.jpg",x:"13",y:"33"};is nothing more than some JavaScript code. It is not JSON. Although JSON looks like JavaScript (JS even stands for JavaScript in JSON), it is nothing more than the characters you’re sending. JSON is a format for transferring data. As soon as you “unpack” it (either in JavaScript or PHP) then it’s not called JSON anymore.