javascript -php - html5 [英] javascript -php - html5

查看:94
本文介绍了javascript -php - html5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

< html> 
< head>
< title> < / title >
< meta http-equiv = Content-Type content = text / html; charset = UTF-8>
< script src = http://ajax.googleapis.com/ajax/libs/jquery/ 1.8.2 / jquery.min.js> < /脚本>
< script type = text / javascript>
$( document )。ready( function (){

});
function sendPushNotification(id){
var data = $(' form#' + id).serialize();
$(' form#' + id).unbind(' submit');
$ .ajax({
url: send_message.php
类型:' GET'
data:data,
beforeSend : function (){

},
成功: function (data,textStatus,xhr){
$(' 。txt_message')。val( );
},
错误: function (xhr,textStatus,errorThrown){

}
});
return false ;
}
< / script>
< / head >
< body>
<?php
include_once ' db_functions.php';
$ db = new DB_Functions();
$ users = $ db-> getAllUsers();
if ($ users!= false
$ no_of_users = mysql_num_rows($用户);
else
$ no_of_users = 0 ;
?>
< div class = container >
< h1>注册的设备数量:<?php echo $ no_of_users; ?> < / h1 >
< hr />
< ul class = devices >
<?php
if ($ no_of_users> 0 ){
?>
<?php
while ($ row = mysql_fetch_array($ users)){
?>
< li>
< form id = <?php echo $ row [ id ]?> name = < span class =code-string>
method = post onsubmit = < span class =code-string>
return sendPushNotification('<?php echo $ row [ id ]?>')>
< label>名称:< / label > < span><?php echo $ row [ name]?> < / span >
< div class = clear> < / div >
< label>电子邮件:< / label < span class =code-keyword>>
< span><?php echo $ row [ 电子邮件]?> & lt; / span >
< div class = clear> < / div >
< div < span class =code-keyword> class = send_container>
< textarea rows = 3 name = message cols = 25 class = txt_message placeholder = 在此处输入消息> < / textarea >
< input type = hidden name = regId value = <?php echo $ row [ gcm_regid ]? >中 />
< input type = submit class = send_btn value = 发送önclick= />
< / div >
< / 表格 >
< / li >
<?php}
} else {?>
< li>
没有注册用户!
< / li >
<?php}?>
< / ul >
< / div >
< / body > < code>< pre>< pre lang = Javascript >

解决方案

document )。ready( function (){

});
function sendPushNotification(id){
var data =


' form#' + id).serialize();

' form#' + id).unbind(' submit');


<html>
   <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">    </script>
    <script type="text/javascript">
        $(document).ready(function(){

        });
        function sendPushNotification(id){
            var data = $('form#'+id).serialize();
            $('form#'+id).unbind('submit');
            $.ajax({
                url: "send_message.php",
                type: 'GET',
                data: data,
                beforeSend: function() {

                },
                success: function(data, textStatus, xhr) {
                      $('.txt_message').val("");
                },
                error: function(xhr, textStatus, errorThrown) {

                }
            });
            return false;
        }
    </script>
</head>
<body>
    <?php
    include_once 'db_functions.php';
    $db = new DB_Functions();
    $users = $db->getAllUsers();
    if ($users != false)
        $no_of_users = mysql_num_rows($users);
    else
        $no_of_users = 0;
    ?>
    <div class="container">
        <h1>No of Devices Registered: <?php echo $no_of_users; ?></h1>
        <hr/>
        <ul class="devices">
            <?php
            if ($no_of_users > 0) {
                ?>
                <?php
                while ($row = mysql_fetch_array($users)) {
                    ?>
                    <li>
                        <form id="<?php echo $row["id"] ?>" name="" method="post" onsubmit="return sendPushNotification('<?php echo $row["id"] ?>')">
                            <label>Name: </label> <span><?php echo $row["name"] ?></span>
                            <div class="clear"></div>
                            <label>Email:</label> <span><?php echo $row["email"] ?></span>
                            <div class="clear"></div>
                            <div class="send_container">
                                <textarea rows="3" name="message" cols="25" class="txt_message" placeholder="Type message here"></textarea>
                                <input type="hidden" name="regId" value="<?php echo $row["gcm_regid"] ?>"/>
                                <input type="submit" class="send_btn" value="Send"  önclick=""/>
                            </div>
                        </form>
                    </li>
                <?php }
            } else { ?>
                <li>
                    No Users Registered Yet!
                </li>
            <?php } ?>
        </ul>
    </div>
</body><code><pre><pre lang="Javascript">

解决方案

(document).ready(function(){ }); function sendPushNotification(id){ var data =


('form#'+id).serialize();


('form#'+id).unbind('submit');


这篇关于javascript -php - html5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆