我是WebOS Dev新手,刚刚在一周前开始工作。所以,需要一点帮助。 从最近2天起,我陷入了一个问题。 我想显示我的服务器端数据到客户端手机,在手掌示例项目的帮助下,我能够在客户端手机上显示静态发布的数据(每次显示相同的发布数据值时)。 但是,我想从文本框(显示通过文本框发布的数据)发布值。问题显示服务器端数据mysql到手机WebOS!
如果您已经安装了webOS的SDK,那么你可以找到从这里
C:\Program Files\Palm\SDK\share\samplecode\samples\Data\.... 的源代码只是试图运行这两个方法AJAX GET和AJAX文章中,我希望做一些事情像AJAX GET方法(谷歌EX)
我修改后的代码是
ajaxPost-assistant.js(我想其中,通过该页面发布这些代码,并显示数据)添加文本框
var myassistant = null;
function AjaxPostAssistant()
{
}
AjaxPostAssistant.prototype.setup=function()
{
myassistant = this;
this.textFieldAtt = {
hintText: 'hint',
textFieldName: 'name',
modelProperty: 'original',
multiline: false,
disabledProperty: 'disabled',
focus: true,
modifierState: Mojo.Widget.capsLock,
limitResize: false,
holdToEnable: false,
focusMode: Mojo.Widget.focusSelectMode,
changeOnKeyPress: true,
textReplacement: false,
maxLength: 30,
requiresEnterKey: false
};
this.model = {
'original' : 'Palm',
disabled: false
};
this.controller.setupWidget('sendField', this.textFieldAtt, this.model);
this.buttonModel1 = {
buttonLabel : 'Push to send post',
buttonClass : '',
disable : false
}
this.buttonAtt1 = {
//type : 'Activity'
}
this.controller.setupWidget('post_button',this.buttonAtt1,this.buttonModel1)
Mojo.Event.listen(this.controller.get('post_button'),Mojo.Event.tap,this.handlePost.bind(this));
}
AjaxPostAssistant.prototype.handlePost=function(event)
{
var posturl='http://openxcellca.info/Parthvi/webos/ajaxpost1.php';
var postdata='fname=Ajay';
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)
myassistant.controller.get('area-to-update').update('Success!');
else {
myassistant.controller.get('area-to-update').update('Failure!');
}
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);
}
});
}
AjaxPostAssistant.prototype.activate = function(event) {
/* put in event handlers here that should only be in effect when this scene is active. For
example, key handlers that are observing the document */
}
AjaxPostAssistant.prototype.deactivate = function(event) {
/* remove any event handlers you added in activate and do any other cleanup that should happen before
this scene is popped or another scene is pushed on top */
}
AjaxPostAssistant.prototype.cleanup = function(event) {
/* this function should do any cleanup needed before the scene is destroyed as
a result of being popped off the scene stack */
}
ajaxPost-scene.htm
ajaxpost1.php
$con = mysql_connect("localhost","user","pwd");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("db", $con);
$qry = "SELECT * FROM user WHERE fname='.$_POST['fname'].'";
$result = mysql_query($qry);
while($row = mysql_fetch_array($result))
{
echo "Name:-".$row['fname'];
echo "
";
echo "E-mail:-".$row['email'];
echo "
";
echo "Phone:-".$row['phone'];
echo "
";
}
mysql_close($con);
?>
请帮助我,我想打一个同步应用程序为我的大学项目。 我需要在这3周内完成。
+0
我对你的问题到底有什么不确定,但看着你的代码,它的哪些组件还没有按你想要的方式工作?服务器端的PHP是否已经做好了正确的事情,只是你不能让客户端的JavaScript去做你想做的事情? –