pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <bdo id='BknZg'></bdo><ul id='BknZg'></ul>
    <i id='BknZg'><tr id='BknZg'><dt id='BknZg'><q id='BknZg'><span id='BknZg'><b id='BknZg'><form id='BknZg'><ins id='BknZg'></ins><ul id='BknZg'></ul><sub id='BknZg'></sub></form><legend id='BknZg'></legend><bdo id='BknZg'><pre id='BknZg'><center id='BknZg'></center></pre></bdo></b><th id='BknZg'></th></span></q></dt></tr></i><div class="cmeci62" id='BknZg'><tfoot id='BknZg'></tfoot><dl id='BknZg'><fieldset id='BknZg'></fieldset></dl></div>
    1. <tfoot id='BknZg'></tfoot>

      <small id='BknZg'></small><noframes id='BknZg'>

    2. <legend id='BknZg'><style id='BknZg'><dir id='BknZg'><q id='BknZg'></q></dir></style></legend>

      為什么我看到“未定義"的值?當我在 jQuery M

      Why am I seeing a value of quot;undefinedquot; on screen when I submit form in jQuery Mobile?(為什么我看到“未定義的值?當我在 jQuery Mobile 中提交表單時在屏幕上?)

        <bdo id='ST7WC'></bdo><ul id='ST7WC'></ul>

          <tfoot id='ST7WC'></tfoot>

            1. <legend id='ST7WC'><style id='ST7WC'><dir id='ST7WC'><q id='ST7WC'></q></dir></style></legend>
              <i id='ST7WC'><tr id='ST7WC'><dt id='ST7WC'><q id='ST7WC'><span id='ST7WC'><b id='ST7WC'><form id='ST7WC'><ins id='ST7WC'></ins><ul id='ST7WC'></ul><sub id='ST7WC'></sub></form><legend id='ST7WC'></legend><bdo id='ST7WC'><pre id='ST7WC'><center id='ST7WC'></center></pre></bdo></b><th id='ST7WC'></th></span></q></dt></tr></i><div class="0ameagq" id='ST7WC'><tfoot id='ST7WC'></tfoot><dl id='ST7WC'><fieldset id='ST7WC'></fieldset></dl></div>

            2. <small id='ST7WC'></small><noframes id='ST7WC'>

                <tbody id='ST7WC'></tbody>

                本文介紹了為什么我看到“未定義"的值?當我在 jQuery Mobile 中提交表單時在屏幕上?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                這是我的 contactus.html 頁面.我正在提交到服務器上的一個 php 頁面,該頁面將獲取信息并發送電子郵件并表示感謝.當我提交表單時,盡管我能夠收到電子郵件,但我在屏幕上看到的只是未定義".

                <頭><title>聯系我們</title><link rel="stylesheet" href="css/latestjquerymobile.css"/><link rel="stylesheet" type="text/css" href="css/jquery.mobile.simpledialog.min.css"/><script type="text/javascript" src="js/jquery-1.6.1.min.js"></script><script type="text/javascript" src="js/latestjquerymobile.js"></script><script type="text/javascript" src="js/jquery.mobile.simpledialog.min.js"></script><script type="text/javascript">$(document).ready(function() {$("#contactus").submit(function(event) {alert("頁面提交");})});<身體><div data-role="page" data-theme="e" id="contactus"><div data-role="header" data-position="fixed"><h1>聯系我們</h1><a href="home.html" data-icon="back" class="ui-btn-left" data-ajax="false">返回</a><a href="home.html" data-icon="home" class="ui-btn-right" data-ajax="false">首頁</a></div><!--/header --><div data-role="內容"><div align="center"><form action="http://testsite.com/contactus.php" name="contactus" id="contactus" method="post"><字段集><div data-role="fieldcontain"><label for="name">名稱:</label><input id="name" name="name" type="text"/><label for="email">電子郵件:</label><input id="email" name="email" type="text"/><label for="contact">聯系人:</label><input id="contact" name="contact" type="text"/><label for="message">消息:</label><textarea rows="4" cols="50" id="message" name="message"></textarea><br/><button type="submit" name="submit" value="submit-value">發送</button></fieldset>

                </表單><div><br><br><a ><img src="images/facebook.png" border="0"/></a><a ><img src="images/twitter.png" border="0"/></a>

                </div><!--/content --></div><!--/page -->

                這是服務器上contactus.php的代碼

                <身體>謝謝

                解決方案

                我不知道你為什么看到 undefined,但我注意到你沒有阻止默認提交操作.所以你的頁面仍然會提交而不是執行 JS.

                您需要做幾件事:

                1. 阻止默認操作(即提交)
                2. 序列化您的表單數據并通過 ajax 提交.

                所以在代碼中它看起來像這樣:

                $(document).ready(function() {//緩存DOM引用var form = $("#contactus");表單.提交(功能(事件){//防止表單常規(非js)提交event.preventDefault();//序列化你的數據,使用jQuery讓它更容易var data = form.serialize();//通過ajax提交$.post(form.attr('動作'),數據,功能(響應){//您應該修改您的PHP以返回成功或錯誤代碼,然后//在這里適當地處理 - 例如 if (response === 'success") {...});});});

                This is my contactus.html page. I am submitting to a php page on the server that is to take the information and send email alongw ith saying thank you. When I do submitthe form, all I see is "undefined" on screen even though I am able to get the email.

                <!DOCTYPE html> 
                <html> 
                    <head> 
                    <title>Contact Us</title> 
                    <link rel="stylesheet" href="css/latestjquerymobile.css" />
                    <link rel="stylesheet" type="text/css" href="css/jquery.mobile.simpledialog.min.css" />
                
                    <script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
                    <script type="text/javascript" src="js/latestjquerymobile.js"></script>
                    <script type="text/javascript" src="js/jquery.mobile.simpledialog.min.js"></script>
                
                
                    <script type="text/javascript">
                    $(document).ready(function() { 
                
                                     $("#contactus").submit(function(event) {
                
                                     alert("page submitted");
                
                
                 })
                
                });
                </script>
                </head> 
                <body> 
                
                <div data-role="page" data-theme="e" id="contactus">
                
                    <div data-role="header" data-position="fixed">
                        <h1>Contact Us</h1>
                        <a href="home.html" data-icon="back" class="ui-btn-left" data-ajax="false">Back</a>
                        <a href="home.html" data-icon="home" class="ui-btn-right" data-ajax="false">Home</a>
                    </div><!-- /header -->
                
                    <div data-role="content">   
                
                    <div align="center">
                
                
                
                
                
                    <form action="http://testsite.com/contactus.php" name="contactus" id="contactus" method="post">
                
                
                    <fieldset>
                
                
                
                        <div data-role="fieldcontain">
                
                        <label for="name"> Name:</label>    
                        <input id="name" name="name" type="text" />
                
                        <label for="email">Email:</label>       
                        <input id="email" name="email" type="text" />
                
                
                        <label for="contact">Contact:</label>   
                        <input id="contact" name="contact" type="text" />
                
                
                        <label for="message">Message:</label>       
                        <textarea rows="4" cols="50" id="message" name="message"></textarea>
                
                        <br />
                        <button type="submit" name="submit" value="submit-value">Send</button>
                
                
                        </fieldset>
                    </div>
                    </form>
                
                
                
                
                     <div><br><br>
                
                
                      <a ><img src="images/facebook.png" border="0" /></a>
                
                    <a ><img src="images/twitter.png" border="0" /></a>
                
                
                     </div>
                
                
                
                
                    </div>
                
                    </div><!-- /content -->
                
                </div><!-- /page -->
                
                </body>
                </html>
                

                This is the code for contactus.php on server

                <?php 
                $ToEmail = 'test@testemail.com'; 
                $EmailSubject = 'Contact Form Submission from testsite.com'; 
                $mailheader = "From: ".$_POST["email"]."
                "; 
                $mailheader .= "Reply-To: ".$_POST["email"]."
                "; 
                $mailheader .= "Content-type: text/html; charset=iso-8859-1
                "; 
                $MESSAGE_BODY = "Name: ".$_POST["name"]."<br>"; 
                $MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>"; 
                $MESSAGE_BODY .= "Contact: ".$_POST["contact"]."<br>";
                $MESSAGE_BODY .= "Message: ".$_POST["message"]."<br>"; 
                mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); 
                ?>
                <html>
                <body>
                
                THANK YOU
                
                </body>
                </html>
                

                解決方案

                I'm not sure why you're seeing undefined, but I noticed you are not preventing the default submit action. so your page will still submit rather than executing JS.

                You'll need to do a couple things:

                1. Prevent the default action (ie the submission)
                2. Serialize your form data and submit it via ajax.

                So in code it would look something like this:

                $(document).ready(function() { 
                    //Cache DOM reference
                    var form = $("#contactus");
                
                    form.submit(function(event) {
                        //Prevent the form from regular (non-js) submission
                        event.preventDefault();
                
                        //Serialize your data, using jQuery to make it easer
                        var data = form.serialize();
                
                        //Submit via ajax
                        $.post(
                          form.attr('action'),
                          data,
                          function(response) {
                            //You should modify your PHP to return a success or error code, then
                            //handle appropriately here - eg if (response === 'success") {...
                          }    
                        );
                
                     });
                
                });
                

                這篇關于為什么我看到“未定義"的值?當我在 jQuery Mobile 中提交表單時在屏幕上?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                PHP PDO ODBC connection(PHP PDO ODBC 連接)
                Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)

                <small id='gHaVC'></small><noframes id='gHaVC'>

              1. <tfoot id='gHaVC'></tfoot>
              2. <legend id='gHaVC'><style id='gHaVC'><dir id='gHaVC'><q id='gHaVC'></q></dir></style></legend>
                  <bdo id='gHaVC'></bdo><ul id='gHaVC'></ul>

                    <i id='gHaVC'><tr id='gHaVC'><dt id='gHaVC'><q id='gHaVC'><span id='gHaVC'><b id='gHaVC'><form id='gHaVC'><ins id='gHaVC'></ins><ul id='gHaVC'></ul><sub id='gHaVC'></sub></form><legend id='gHaVC'></legend><bdo id='gHaVC'><pre id='gHaVC'><center id='gHaVC'></center></pre></bdo></b><th id='gHaVC'></th></span></q></dt></tr></i><div class="mqwe0ae" id='gHaVC'><tfoot id='gHaVC'></tfoot><dl id='gHaVC'><fieldset id='gHaVC'></fieldset></dl></div>

                    主站蜘蛛池模板: 标准件-非标紧固件-不锈钢螺栓-非标不锈钢螺丝-非标螺母厂家-三角牙锁紧自攻-南京宝宇标准件有限公司 | 蜘蛛车-登高车-高空作业平台-高空作业车-曲臂剪叉式升降机租赁-重庆海克斯公司 | 蔬菜清洗机_环速洗菜机_异物去除清洗机_蔬菜清洗机_商用洗菜机 - 环速科技有限公司 | 武汉高低温试验机-现货恒温恒湿试验箱-高低温湿热交变箱价格-湖北高天试验设备 | 粉碎机_塑料粉碎机_塑料破碎机厂家-星标机械 | 不锈钢/气体/液体玻璃转子流量计(防腐,选型,规格)-常州天晟热工仪表有限公司【官网】 | 合肥废气治理设备_安徽除尘设备_工业废气处理设备厂家-盈凯环保 合肥防火门窗/隔断_合肥防火卷帘门厂家_安徽耐火窗_良万消防设备有限公司 | 煤棒机_增碳剂颗粒机_活性炭颗粒机_木炭粉成型机-巩义市老城振华机械厂 | 红立方品牌应急包/急救包加盟,小成本好项目代理_应急/消防/户外用品加盟_应急好项目加盟_新奇特项目招商 - 中红方宁(北京) 供应链有限公司 | 南溪在线-南溪招聘找工作、找房子、找对象,南溪综合生活信息门户! | 北京租车牌|京牌指标租赁|小客车指标出租 | 海峰资讯 - 专注装饰公司营销型网站建设和网络营销培训 | 临时厕所租赁_玻璃钢厕所租赁_蹲式|坐式厕所出租-北京慧海通 | GEDORE扭力螺丝刀-GORDON防静电刷-CHEMTRONICS吸锡线-上海卓君电子有限公司 | 电力电子产业网 | 越南专线物流_东莞国际物流_东南亚专线物流_行通物流 | 精益专家 - 设备管理软件|HSE管理系统|设备管理系统|EHS安全管理系统 | 连栋温室大棚建造厂家-智能玻璃温室-薄膜温室_青州市亿诚农业科技 | 细石混凝土泵_厂家_价格-烟台九达机械有限公司 | COD分析仪|氨氮分析仪|总磷分析仪|总氮分析仪-圣湖Greatlake | 土壤墒情监测站_土壤墒情监测仪_土壤墒情监测系统_管式土壤墒情站-山东风途物联网 | 垃圾压缩设备_垃圾处理设备_智能移动式垃圾压缩设备--山东明莱环保设备有限公司 | 蓝牙音频分析仪-多功能-四通道-八通道音频分析仪-东莞市奥普新音频技术有限公司 | BESWICK球阀,BESWICK接头,BURKERT膜片阀,美国SEL继电器-东莞市广联自动化科技有限公司 | 石膏基自流平砂浆厂家-高强石膏基保温隔声自流平-轻质抹灰石膏粉砂浆批发-永康市汇利建设有限公司 | 自动部分收集器,进口无油隔膜真空泵,SPME固相微萃取头-上海楚定分析仪器有限公司 | 菲希尔X射线测厚仪-菲希尔库伦法测厚仪-无锡骏展仪器有限责任公司 | 二手Sciex液质联用仪-岛津气质联用仪-二手安捷伦气质联用仪-上海隐智科学仪器有限公司 | 超细粉碎机|超微气流磨|气流分级机|粉体改性设备|超微粉碎设备-山东埃尔派粉碎机厂家 | 领先的大模型技术与应用公司-中关村科金 | 干洗店加盟_洗衣店加盟_干洗店设备-伊蔻干洗「武汉总部」 | 中药超微粉碎机(中药细胞级微粉碎)-百科 | 袋式过滤器,自清洗过滤器,保安过滤器,篮式过滤器,气体过滤器,全自动过滤器,反冲洗过滤器,管道过滤器,无锡驰业环保科技有限公司 | 无机纤维喷涂棉-喷涂棉施工工程-山东华泉建筑工程有限公司▲ | 焊接减速机箱体,减速机箱体加工-淄博博山泽坤机械厂 | 艺术涂料|木纹漆施工|稻草漆厂家|马来漆|石桦奴|水泥漆|选加河南天工涂料 | 鹤壁创新仪器公司-全自动量热仪,定硫仪,煤炭测硫仪,灰熔点测定仪,快速自动测氢仪,工业分析仪,煤质化验仪器 | 台式恒温摇床价格_大容量恒温摇床厂家-上海量壹科学仪器有限公司 | 铝合金风口-玻璃钢轴流风机-玻璃钢屋顶风机-德州东润空调设备有限公司 | 耐酸碱胶管_耐腐蚀软管总成_化学品输送软管_漯河利通液压科技耐油耐磨喷砂软管|耐腐蚀化学软管 | 昊宇水工|河北昊宇水工机械工程有限公司 |