I need a function to return the current instance as a json text, because I will send the values with an ajax request to server side script.
I don’t know where to use the “this” keyword in a jquery selector
function Actor(){
this.input=function(pname,ppassword){
this.name=pname;
this.password=ppassword;
}
//I need a function to return the current instance as a json text here
//I will send the values with an ajax request to server side script with a function
}
I’ve found out that jquery doesn’t support encoding as JSON and I need to use JSON2.js for serializing as JSON string.
New browsers have native JSON support so you can use JSON.stringify without including JSON2.js
You may need to be more specific in your question but if you need this in the input function to be a JSON string, you can use:
See here for JSON libraries for older browsers that don’t support JSON object natively: https://github.com/douglascrockford/JSON-js