Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 向手机WebOS显示服务器端数据mysql时出现问题!_Php_Ajax_Jquery_Webos - Fatal编程技术网

Php 向手机WebOS显示服务器端数据mysql时出现问题!

Php 向手机WebOS显示服务器端数据mysql时出现问题!,php,ajax,jquery,webos,Php,Ajax,Jquery,Webos,我是WebOS开发新手,一周前刚开始工作。所以,我需要一点帮助。 从过去的两天起,我就陷入了一个问题。 我想向客户端手机显示我的服务器端数据,借助palm示例项目,我能够在客户端手机上显示静态发布数据(每次显示相同的发布数据值)。 但是,我想从文本框中发布值(显示通过文本框发布的数据)。 var myassistant = null; function AjaxPostAssistant() { } AjaxPostAssistant.prototype.setup=function() {

我是WebOS开发新手,一周前刚开始工作。所以,我需要一点帮助。 从过去的两天起,我就陷入了一个问题。 我想向客户端手机显示我的服务器端数据,借助palm示例项目,我能够在客户端手机上显示静态发布数据(每次显示相同的发布数据值)。 但是,我想从文本框中发布值(显示通过文本框发布的数据)。

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 */
}
如果您已经安装了webos SDK,那么您可以从这里找到源代码

C:\ProgramFiles\Palm\SDK\share\samplecode\samples\Data\..
只要试着运行方法ajaxget和ajaxpost,我想做一些类似于ajaxget方法(googleex.)的事情

我修改的代码是

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

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 */
}
<div x-mojo-element="Button" id="post_button"></div>

<div id="area-to-update"></div>
<br>
<div id="server-response"></div>


ajaxpost1.php

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 */
}
<?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 "<br />";
  echo "E-mail:-".$row['email'];
  echo "<br />";
  echo "Phone:-".$row['phone'];
  echo "<br />";
  }

mysql_close($con);
?>

请帮助我,我想为我的大学项目制作一个同步应用程序。
我需要在这3周内完成。

我不是WebOS专家,但首先要确保您的php服务器端脚本正在发送JSON。更清楚的是要处理回答:见我的问题


那应该很简单。

我不是WebOS专家,但首先要确保您的php服务器端脚本正在发送JSON。更清楚的是要处理回答:见我的问题


那应该很简单。

我不确定您的问题到底是什么,但看看您的代码,它的哪些组件还没有按您希望的方式运行?服务器端PHP是否已经做了正确的事情,只是你不能让客户端JavaScript做你想做的事情?我有点不确定你的问题到底是什么,但看看你的代码,它的哪些组件还没有按你希望的方式工作?服务器端PHP是否已经做了正确的事情,只是您无法让客户端JavaScript做您想做的事情?