Results 1 to 5 of 5
  1. cooltpmd's Avatar
    Posts
    75 Posts
    Global Posts
    77 Global Posts
       #1  
    Is there a decent tutorial for capturing the results of a web query so that it can be used in an application.

    An example I have seen: ... use an application to send a query to Google ... gather the results of that query so that you can display it in your application ... then formatting the data in your application window?

    It's done all the time, but my searches for instruction have been empty.

    Thanks in advance!!!
  2. #2  
    To take your Google example, these are not per sya "web queries" as you are not doing an SQL query to a database. Most of the time, what you see parse XML files that holds the data.
    To do a real query toward a database server (MS SQL, MySQL,...) you use SQL queries usually written in PhP, ASP, Coldfusion... most of the time. To my knowledge, you cannot run these languages in a Pre App. You can only run HTML, CSS, and JavaScript, which goes back to using XML files and parsing them.
    The only way to use php, CF, ASP.... is do develop a web app, which runs through the Pre web browser.
  3. cooltpmd's Avatar
    Posts
    75 Posts
    Global Posts
    77 Global Posts
       #3  
    Agreed. I am not seeking to tap a websites database. But what I want to learn how to do is send a search to a website from the Pre, capture the results from the website, then format it for the Pre. The Homebrew translator, weather, package tracker all use it ... i literally cannot find a discussion anywhere on how to do it.
  4. #4  
    try using ajax request/response. I am doing the same sort of thing, untested so far, so i can't claim that this code is working, but this is the direction. I put this first bit of code in the MySceneAssistant.prototype.setup function.

    Code:
    // Get the file via ajax request
    	this.searchTerm="something+with+plus+sign+for+spaces"
    	this.url= "http://www.google.com/search?q=" + this.searchTerm + "&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a"
    	try{
    		this.request = new Ajax.Request(this.url, 
    				{
    					method: "get",
    					evalJSON: "false",
    					onSuccess: this.searchSuccess.bind(this),
    					onFailure: this.searchFailure.bind(this)
    				}
    			);
    	}catch(error){
    		this.showDialogBox("error opening file", error);
    	}
    Code:
    MySceneAssistant.prototype.searchSuccess= function(transport){
    	// Put the response into the scene
    	try{
    		var theData= transport.responseXML;
    		this.controller.get("searchResult").innerHTML= theData;
    	}catch (error) {
    		showDialogBox("Success Error", error)
    	}
    }
    Code:
    MySceneAssistant.prototype.searchFailure= function(transport){
    	try{
    		$("searchresult").innerHTML= "Something went wrong!";
    	}catch (error) {
    		showDialogBox("Failure Error", error)
    	}
    }
    Code:
    MySceneAssistant.prototype.showDialogBox = function(t,msg){
    		this.controller.showAlertDialog({
    		onChoose: function(value) {},
    		title: t,
    		message: msg,
    		choices:[ {label:'OK', value:'OK', type:'color'} ]
    	});
    }
  5. #5  
    look in the Data sample code in the SDK references. it shows an ajax get example to query google.

Posting Permissions