Wednesday, June 14, 2006

JSON for Dummies part 2

Below are clipping from My Portal Project, JSON for Dummies part 2:

Change the JSON response so that we have a method called “actionToTake”, and call it directly:

{"actionToTake" :
alert('The description and category fields are required.');

In the above sample we created the “actionToTake” object as a function, with no parameters. Now we can use the following code to process our action:

function processJsonResponse(originalRequest){
var domText = originalRequest.responseText;
var jsonResult = eval("(" + domText + ")");

This is another example of JSON strength.

1 comment:

8hhkmbq3 said...
This comment has been removed by a blog administrator.