Results 1 to 2 of 2
  1. wfcentral's Avatar
    75 Posts
    Global Posts
    76 Global Posts
    I'm trying to pull a "name" and "points" out of a JSON data string I'm pulling from my server.

    I can get the following data from my server as "responseText"


    I just can't figure out how to modify the code below so it passes "name" and "points" to the scene...

    I've been through numerous sites - prototype, javascript sites, palm dev sites... everything I try just gives me "order order" (meaning I'm doing something wrong)

    var myAjax = new Ajax.Request(posturl, {
    	method: 'post',
    	evalJSON: 'force',
    	postBody: postdata,
    	contentType: 'application/x-www-form-urlencoded',
    		onComplete: function(transport){
    			if (transport.status == 200) 
    			else {
    				myassistant.controller.get('server-response').update('Server Response: \n' + transport.responseText);	
    			onFailure: function(transport){
    				myassistant.controller.get('area-to-update').update('Failure!\n\n' + transport.responseText);
  2. moserjj's Avatar
    468 Posts
    Global Posts
    470 Global Posts
    in your onSuccess function, you would do something like this to assign your responseText as a JSON object

    var r = transport.responseText.evalJSON();

    then, you could access the the values with r.username and r.points

Posting Permissions