PDA

View Full Version : help loading data to form......



rex0098
15 Dec 2009, 7:30 PM
hi every one i don't know how many times i've already posted about the same question and i thank you for some replies that i received but i still cant get my code working.....based on advices a got on this forum i think my code is correct, i get the correct response in firebug....


{ sucess: true,data : {first_name : "raymund",last_name :"olsen"}}


using my getdata.php to get data from my databse..


$dbhost = "localhost"; // this will ususally be 'localhost', but can sometimes differ
$dbname = "test2"; // the name of the database that you are going to use for this project
$dbuser = "root"; // the username that you created, or were given, to access your database
$dbpass = "root"; // the password that you created, or were given, to access your database

$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die("MySQL Error: " . mysql_error());
mysql_select_db($dbname) or die("MySQL Error: " . mysql_error());


$result=mysql_query ("SELECT first_name,last_name FROM names WHERE name_id = '2'") or die (mysql_error ());
$get_result = mysql_fetch_array($result);
$first_name = $get_result['first_name'];
$last = $get_result['last_name'];

echo '{ sucess: true,data : {first_name : "'.$first_name.'",last_name :"'.$last.'"}}';


but every time i run my code it always prompts a load failed message....
this is my code at the moment:


Ext.onReady(function(){

Ext.QuickTips.init();

var fieldset1 =
{
xtype : 'fieldset', // 1
flex : 1,
border : false, // 2
labelWidth : 60,
defaultType : 'field',
defaults : {anchor : '-10',allowBlank : false},
items :
[{
fieldLabel : 'First',
name : 'first_name'
},
{
fieldLabel : 'Last',
name : 'last_name'
}]
}


var fieldsetContainer =
{
xtype : 'container',
layout : 'hbox',
height : 120,
layoutConfig : {
align : 'stretch'
},
items : [fieldset1]
}

var myFormPanel = new Ext.form.FormPanel({
renderTo : Ext.getBody(),
width : 200,
title : 'Our complex form',
height : 100,
frame : true,
id : 'myFormPanel',
layout : 'vbox',
layoutConfig : {
align : 'stretch'
},
items : [fieldsetContainer]
});

var form = Ext.getCmp('myFormPanel');
form.getForm().load({
url : 'getdata.php',
root:'data',
failure:function(form, action) {
Ext.MessageBox.alert('Message', 'Load failed');
},
success:function(form, action) {
Ext.MessageBox.alert('Message', 'Load succeed.');
}
});
});


somebody please help me.....

CrazyEnigma
16 Dec 2009, 9:06 AM
If I read your post correctly. success is spelled incorrectly.

rex0098
16 Dec 2009, 4:49 PM
enigma,

rex0098
16 Dec 2009, 4:51 PM
enigma thank you...i already changed the misspelled word after i first posted this thread..:D

CrazyEnigma
16 Dec 2009, 8:06 PM
So is it solved or not? If so, please change your post to [SOLVED]