<div class="codetitle"> <span><a style="CURSOR: pointer" data="15272" class="copybut" id="copybut15272" onclick="doCopy('code15272')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code15272"> <br><dt style="margin:15px 0px 3px; padding:0px; border:0px; font-weight:bold; color:rgb(4,121,167); font-family:Verdana,Arial,宋体; background-color:rgb(249,249,249)">dataType <br>类型:String <br>预期服务器返回的数据类型。如果不指定,jQuery 将自动根据 HTTP 包 MIME 信息来智能判断,比如 XML <br>MIME 类型就被识别为 XML <br> </dt> <dt style="margin:15px 0px 3px; padding:0px; border:0px; font-weight:bold; color:rgb(4,121,167); font-family:Verdana,Arial,宋体; background-color:rgb(249,249,249)"> <br> </dt> <br> </div> <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="6986" class="copybut" id="copybut6986" onclick="doCopy('code6986')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code6986"> <br> <br><script type="text/javascript" src="jquery-1.8.2.min.js"></script> <br><script type="text/javascript"> <BR>function text(){ <BR>// alert($("input[name='text']").val()+"aaaaaaaaa"); <BR>// post 传值 <BR>$.post( <BR>"index.php", //引号不能忘记加 <BR>{ <BR>val:$("input[name='text']").val() <BR>}, <BR>function(data){ <BR>if(data=='1'){ <BR>alert("这是text传值 传递过来的值是"+data); <BR>} <BR>}, <BR>"text" //引号不能忘记加 <BR>) <BR>} <br><br>function json(){ <BR>//get 传值 <BR>$.get( <BR>"index1.php", <BR>{ <BR>val:$("input[name='json']").val() <BR>}, <BR>function(data){ <BR>if(data=='1'){ <BR>alert("这是json传值 值为"+data); <BR>} <BR>}, <BR>'json' <BR>) <BR>} <br><br></script> <br> <br><input type="txt" name="text" id="text" onblur="text()"><span>dataType值为text</span><br> <br><input type="text" name="json" onblur="json()"><span>dataType值为json</span><br> <br> <br> <br> </div> <br>index.php代码 <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="84959" class="copybut" id="copybut84959" onclick="doCopy('code84959')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code84959"> <br><?php <BR>echo "1"; <br>?> <br> </div> <br>index1.php代码 <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="24480" class="copybut" id="copybut24480" onclick="doCopy('code24480')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code24480"> <br><?php <BR>ECHO json_encode("1"); <br>?> <br> </div>