JQuery Ajax data - how to send a "object in object" to JSON server?
Hello to all,
i have a problem to send a "object in object" as json ajax data to a webservice.
My jquery code:
- $.ajax({
- type: "POST",
- url: "http://localhostl/webservice/service.php?JSON",
- data: {
- "call" : "IsSessionValid",
- "request" : [{
- "apiRequestHeader" : {
- "sessionToken" : "XXXXXXXXXXXXXXXXXXXXXXXXXX"
- }
- }]
- },
- success: function(data){alert("OK: " + data);},
- failure: function(errMsg) {
- alert("ERROR: " + errMsg);
- }
- });
As you can see, my send data needs to be a "class in class" or "object in object" (The code is cutted a little bit to not confuse you). Here a example how the object looks like in php:
- $myObject = new MyObject();
- $myObject->apiRequestHeader = new ApiRequestHeader();
- $myObject->apiRequestHeader->sessionToken = "XXXXXX";
- $myObject->bla = "xxx";
- ...
- ...
I know that the http transfer has the syntax "param1=value1¶m2=value2...", but i need to pass a real object to the server.
Can me help anybody to understand how to make it work? Or is there now way to do this with json + jquery?
Thank you for your time!
Greets,
Marty McFly ;)