Found Ajax is really good dongdong: You can only pass the XML simple client want data.
Client Ajax Code:
Initiates a XMLHTTP request to the server.var http_request = null;function GetData (){Start initializing the XMLHttpRequest objectif (window.
Lifting Async, the first thing to think about is Ajax, but for scenarios where it's inconvenient to use Ajax, for example, we want to upload a file using Servlet 3.0, we also need to submit some form information, how to first commit the file
var WebMethod = "Http://localhost:54473/Service1.asmx/HelloWorld";
jQuery.support.cors = true;
Not before add this sentence always hint no transport, I didn't go deep thought.
$.ajax
({
type: "POST",
One: Demand
To implement the following input box to support fuzzy query, query string: "Nick."
Second: The principle of realization
The input box is bound to the KeyUp event, and then the AJAX request, with input parameters, goes back to the
Asynchronously saves data through jquery. Ajax functions
Practical Examples:
In _form.html.erb:
" data-id= ' ' >
The data that is accepted by input is saved, and the Data-id custom property means that the value of the f.id is saved so that
File one: Front-end template file news.html.
Used to nest PHP statements after loading the database content to produce news.htmls static files.
Articles Home
Data used with Ajax requests
File two: Articlelist.js
The morning of the page to pass the value of the Chinese characters, the data has not gone through. Later colleagues to help solve, in controller layer plus @responsebody
@ResponseBody indicates that the return result of the method is written
first need to import jquery.js Baidu jquery into the official website download on the line note to be placed under the Web-inf
Front-end code:
pageencoding= "UTF-8"%>insert title here Please enter two strings First:Second:button//Submit
After the AJAX request is successfully resolved, a new window is opened and is not blocked by the browser.
1. Be sure to put the window outside
2. Be sure to use synchronous request
var result= "";
Jquery.ajax ({
"type": "Post",
1 The Done method in Ajax can be used after version 1.5 of jquery. This method has a similar effect as success in Ajax. It must first be after the 1.5 version in jquery.
such as:
2 Ajax's done. Parameters can be written as a method. is a
$.ajax of jquery (Url,[settings])1. The default contenttype value is: application/x-www-form-urlencoded; Charset=utf-8This format is the form submission format, the data is key1=value1&key2=value2 format2. Although the Data property value of Ajax is
1. In action
Class Action1 {
Private list deptlist; Give a Get method
Peivate String IDs,-------get Set
Public String functions () {
Deptlist=xiaoserviceimpl.getbyid (IDS)
Return "Ajax";
}
}
Configuration file:
deptlist \ [\ d+ \]\.id,deptlist\ [\
Preface
1.Ajax Overview2.load () method3..get () and. Post ()
Ajax is all called: "Asynchronous JavaScript and XML" (Asynchronous JavaScript and XML), which is not a single technology of JavaScript, but a combination of a series of interactive Web
Preface
1.JSON and JSONP2.jqXHR object one. JSON and JSONP
If the $.ajax () method is in the same domain, the JSON file can be loaded as long as the DataType property is set. In the non-identical domain, JSONP can be used, but it is also
Overtime is to not work overtime.Two parameters passed from the foreground, packed into: {"User": {"name": "ASD", "Age": 22}}Springmvc parameters such as: public void test (@RequestBody user user) { ...}is not received, the property always
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.