Results 1 to 2 of 2
  1.    #1  
    Hi guys,

    I'm trying to develop an application which gets the the response from the MySQL database using ajax post and update in list selector, but the list is displaying empty, can some one help me out from this please.....

    code for html:

     <div class="palm-heahheader">
    	<div class="palm-header middle">
    		<span x-mojo-loc="">List selector</span>	
    	<div class="palm-header-spacer" style="height:60px"></div>
    	<div class="palm-group unlabled">
    		<div class="palm-list">
    			<div class="palm-row" x-mojo-highlight="momentary">
    				<div class="palm-row-wrapper">
    					<div id="firstselector" x-mojo-element="ListSelector"></div>
    code for .jsjsjs:

    SecondAssistant.prototype.setup = function() {
    	/* this function is for setup tasks that have to happen when the scene is first created */
    	/* use Mojo.View.render to render view templates and add them to the scene, if needed */
    	/* setup widgets here */
    	/* add event handlers to listen to events from widgets */
    	/*this.selectorChanged = this.selectorChanged.bindEventListener(this);
    	Mojo.Event.listen(this.controller.get('firstselector'), Mojo.Event.propertyChange, this.selectorChanged);*/
    	this.names = [];
    	try {
    		new Ajax.Request('localhost/xyz.php', {
    since I'm new to this it is not allowing me to add link:(
    method: 'post', parameters: { 'recs': getallrecords, 'q': q }, evalJSON: 'true', onSuccess: function(response){ var json = response.responseJSON; var count = json.count - 1; for(i=0; i<count; i++){ this.names.push({ label: json[i].name, value: '0' }); } }.bind(this), this.controller.modelChanged(this.model); onFailure: function(){ Mojo.Controller.errorDialog('Failed to get ajax response'); } }); } catch (e){ Mojo.Controller.errorDialog(e); } this.controller.setupWidget("firstselector", this.attributes = { label: $L('Name'), modelProperty: 'currentName' }, this.model = { choices: this.names } ); };
    code for php:

    header('Content-type: application/json');  // this is the magic that sets responseJSON
    $conn = mysql_connect('localhost', 'root', '')// creating a connection
    mysql_select_db("test", $conn) or die('could not select the database');//selecting database from connected database connection
    			$q = $_POST['q'];
    			//performing sql operations
    			$query = sprintf("SELECT * FROM user WHERE name= $q");
    			$result = mysql_query($query) or die('Query failed:' .mysql_error());
    			$all_recs = array();
    			while ($line = mysql_fetch_array($result,MYSQL_ASSOC)) {
     			$all_recs[] = $line;
    echo json_encode($all_recs);
    // Free resultset
    // closing connection
    some one help me on this please...
    thank you
    Last edited by noviceuser87877; 05/17/2011 at 04:50 AM.
  2.    #2  
    some one please help me on this issue.....

Tags for this Thread

Posting Permissions