What I want to achieve is passing a json string as Get method to server with jquery. The content that is sent back is html type. I use the function .get(“url”, myJson, callback) to accomplish this.
To make my json string I verify some checkbox and textbox to get their content and add their id/value on the json string if needed.
I used an array that I added my value like:
var array = new Array();
array.push("att_id:"+value);
and then used this to make the json:
var jsonString = "{" + array.join(",") + "}";
But when I make a request to the server like this:
$.get(
"localhost/something",
$jsonString,
function(data){
$("#something").html(data);
});
It doesn’t work cause it pass the jsonString as the arraykey and a null value.
So I’m looking for a method to achieve this.
Try this (quick fix):
Or, more in the spirit of jQuery (since you really want to pass a Javascript key-value map (i.e. an object) rather than a pre-JSON-ified string):