Results 1 to 5 of 5
  1.    #1  
    Just getting into app development for the Pre, and the UI / widget stuff is coming along nicely. My main question right now, however, is how do you handle Ajax requests when you are wanting to pull, say, an xml document off of a remote server? If I remember correctly, there are protections from this which is why typically in web development you would use Ajax to call a local php script, or something similar, that then pulls in the data from the remote site. How is this sort of thing handled with WebOS / Mojo?
  2. #2  
    I have no pre dev experience, but I don't understand what you mean by "ajax request to a local php script". Ajax (web) applications can't acess local files. Maybe you meant on the remote machine?

    Anyway ajax is pretty much built around the xmlhttprequest jsjsjs $object$. $You$ $can$ $use$ $that$ $object$ $to$ $make$ *$any$* $http$ $request$. $I$'$m$ $sure$ $web$ $os$ $has$ $it$'$s$ $own$ $wrappers$ $for$ $making$ $http$ $requests$ $but$ $hopefully$ $this$ $gives$ $you$ $a$ $place$ $to$ $start$.
  3. #3  
    Code:
    new Ajax.Request(url,{
     method: 'get',
     evalJSON: 'false',
     onSuccess: function(transport){
      var response = transport.responseXML;
     },
     onFailure: function(){
      //Stuff to do if the request fails, ie. display error
     }
    });
    Just look at the Prototype page for Ajax requests, and DOM parsing to parse the XML (getElementsByTagName)

    The Pre allows for external domains to be accessed through Ajax. A PHP proxy is not need to pull remote data.
    Sprint Palm Pre - WebOS 2.1 > Sprint HTC Arrive
  4. #4  
    The easiest way is if the server is setup to return json it can be done with xml also.

    var request = new Ajax.Request(url, {
    method: 'get',
    evalJSON: 'force',
    onSuccess: this.gotResults.bind(this),
    onFailure: this.failure.bind(this)
    });
    Take a look at the Palm\SDK\share\samplecode\samples\Data\ example has ajax get for json and an xml parse example also

    lol other guy beat me to it
  5.    #5  
    Quote Originally Posted by TIWizard View Post
    The Pre allows for external domains to be accessed through Ajax. A PHP proxy is not need to pull remote data.
    this is what I was wondering about. good to know.

Posting Permissions