$.ajax () method for data transfer between Web pages _ajax related

Source: Internet
Author: User
ajaxtext1.jsp
Copy Code code as follows:

<%@ page language= "java" import= "java.util.*" pageencoding= "Utf-8"%>
<script type= "Text/javascript" language= "JavaScript" src= "Jquery.js" ></script> <!--must contain Jquery.js file, otherwise the value cannot be passed-->
<script type= "Text/javascript" >
function Fun () {
var SS;
var radio1=document.getelementsbyname ("Radio1"); Read the value of a radio button
for (Var i=0;i<radio1.length;i++) {
if (Radio1.item (i). Checked) {
Ss=radio1.item (i). value;
Break
}
}
var sendstr= "sendstr1=" +form1.text1.value+ "&sendstr2=" +SS;
$.ajax ({
Type: "POST",
URL: "Ajaxtest2.jsp",
Async:false,
DATA:SENDSTR,//can also be used in this way of annotation to carry out a value operation
DATA:{SENDSTR1:FORM1.TEXT1.VALUE,SENDSTR2:SS},//You can also read the element values in Text1 in the way of $ ("#text1"). Val ()
Success:function (data) {
alert (data);
}
});
}
</script>
<body>
<div align= "center" >
<form id= "Form1" Name= "Form1" action= "" method= "POST" >
Input: <input type= "text" name= "Text1" id= "Text1" ><br>
Golden Ball: <input type= "Radio" name= "Radio1" value= "Lionel Messi" > Lionel Messi
<input type= "Radio" name= "Radio1" value= "Ronaldo" >c Luo <br>
<input type= "button" value= "Submit" onclick= "Fun ()" >
</form>
</div>
</body>

ajaxtest2.jsp
Copy Code code as follows:

<pre code_snippet_id= "269881" snippet_file_name= "blog_20140402_4_" 8173458 "class=" JavaScript name= "code" ><%@ page contenttype= "Text/html;charset=utf-8"%>

<%
Request.setcharacterencoding ("Utf-8");
String sendstr1=request.getparameter ("sendstr1");
String sendstr2=request.getparameter ("sendstr2");
String sreturn=sendstr1+ "_new_" +SENDSTR2;
%>
<%=sreturn%></pre><pre code_snippet_id= "269881 snippet_file_name=" blog_20140402_5_ 3124712 "class=" javascript "name=" code "></pre><pre code_snippet_id=" 269881 "Snippet_file_name=" Blog_ 20140402_5_3124712 "class=" JavaScript name= "code" ><H2 class= "Titname sg_txta" id= "T_4f925fc30100la36" > jquery $.ajax () method parameter detailed ask Baidu or Google
<pre></pre>
<div style= "top:177 PX ' > </div>
<pre></pre>
Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.