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>