How can I use JSON-like variable in my function like this?
$.ajax({
type:"POST",
-->data:{this_var:this_value}
});
How can I use JSON-like variable in my function like this?
$.ajax({
type:"POST",
-->data:{this_var:this_value}
});
Your code:
$.ajax({
type:"POST",
-->data:{this_var:this_value}
});
Then to use the object as you mentioned would be:
var myObj = {this_var:this_value};
myObj.this_var();
That is if this_var is a function. Otherwise the value can be consumed such as:
var myObj = {this_var:this_value};
var myVal = myObj.this_var;
You may also need to pass the data in as a string and then parse it as JSON after getting the string from the ajax call.
var myObj = JSON.parse(data);
var myVal = myObj.this_var(); // if this is a function