


Submitting JQuery Mobile forms through AJAX and PHP (two articles)
Submit jQuery Mobile forms via AJAX and PHP
jQuery mobile form submission
http://blog.csdn.net/tjpu_lin/article/details/ 28394253
Recently, I was developing a mobile page using jQuery mobile, and encountered a problem when submitting the form.
The background is processed by servlet. If you want to use the redirection in the servlet to jump to the page and forward it to the mobile phone, it will not work at all. An errorpage message will appear.
After consulting online information and the jQuery mobile API, I learned that jQuery mobile form submission defaults to ajax submission, so the page jump function will not be implemented at all if the page jump is written in the servlet.
So I added the attribute data-ajax="false" to the form according to the tutorial, and found that not only the page jump could not be performed, but also the background database operations could not be performed, and a 500 error was reported.
<?php $firstName = $_POST[firstName]; $lastName = $_POST[lastName]; echo("First Name: " . $firstName . " Last Name: " . $lastName); ?>
<!DOCTYPE html> <html> <head> <title>Submit a form via AJAX</title> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4/jquery.mobile-1.0a4.min.css" /> <script src="http://code.jquery.com/jquery-1.5.2.min.js"></script> <script src="http://code.jquery.com/mobile/1.0a4/jquery.mobile-1.0a4.min.js"></script> </head> <body> <script> function onSuccess(data, status) { data = $.trim(data); $("#notification").text(data); } function onError(data, status) { // handle an error } $(document).ready(function() { $("#submit").click(function(){ var formData = $("#callAjaxForm").serialize(); $.ajax({ type: "POST", url: "callajax.php", cache: false, data: formData, success: onSuccess, error: onError }); return false; }); }); </script> <!-- call ajax page --> <div data-role="page" id="callAjaxPage"> <div data-role="header"> <h1>Call Ajax</h1> </div> <div data-role="content"> <form id="callAjaxForm"> <div data-role="fieldcontain"> <label for="firstName">First Name</label> <input type="text" name="firstName" id="firstName" value="" /> <label for="lastName">Last Name</label> <input type="text" name="lastName" id="lastName" value="" /> <h3 id="notification"></h3> <button data-theme="b" id="submit" type="submit">Submit</button> </div> </form> </div> <div data-role="footer"> <h1>GiantFlyingSaucer</h1> </div> </div> </body> </html>
<script type="text/javascript"> $(document).ready(function () { $("#submitbtn").click(function(){ cache: false, $.ajax({ type: "POST", url: "feedback", data: $('#feedbackform').serialize(), success:function(data){ $.mobile.changePage("success.html"); } }); }); });
The above introduces how to submit JQuery Mobile forms through AJAX and PHP (two articles), including relevant content. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Working with database in CakePHP is very easy. We will understand the CRUD (Create, Read, Update, Delete) operations in this chapter.

Validator can be created by adding the following two lines in the controller.
