jQuery ajax dataType值为text json探索
2013-09-22 21:05
176 查看
dataType
类型:String
预期服务器返回的数据类型。如果不指定,jQuery 将自动根据 HTTP 包 MIME 信息来智能判断,比如 XML
MIME 类型就被识别为 XML
index.php代码
index1.php代码
类型:String
预期服务器返回的数据类型。如果不指定,jQuery 将自动根据 HTTP 包 MIME 信息来智能判断,比如 XML
MIME 类型就被识别为 XML
代码
html代码
<html> <SCRIPT TYPE="text/javascript" src='jquery-1.8.2.min.js'></SCRIPT> <SCRIPT TYPE="text/javascript"> function text(){ // alert($("input[name='text']").val()+"aaaaaaaaa"); // post 传值 $.post( "index.php", //引号不能忘记加 { val:$("input[name='text']").val() }, function(data){ if(data=='1'){ alert("这是text传值\n传递过来的值是"+data); } }, "text" //引号不能忘记加 ) } function json(){ //get 传值 $.get( "index1.php", { val:$("input[name='json']").val() }, function(data){ if(data=='1'){ alert("这是json传值\n值为"+data); } }, 'json' ) } </SCRIPT> <body> <INPUT type='txt' name='text' id='text' onblur='text()' /><span>dataType值为text</span><BR> <INPUT type='text' name='json' onblur='json()'><span>dataType值为json</span><br /> </body> </html>
index.php代码
<?php echo "1"; ?>
index1.php代码
<?php ECHO json_encode("1"); ?>
相关文章推荐
- 使用Gson解析Json为Map对象探索(下)
- spring支持text/html json
- WebApi接口返回json,xml,text纯文本等
- Hive JSON数据处理的一点探索
- Jquery发送ajax请求以及datatype参数为text/JSON方式
- AFNetworking 2.0 获取json数据时,返回 NSLocalizedDescription=Request failed: unacceptable content-type: text/html, 解决方法.
- AFNetworking 关于JSON text did not start with array or object and option to allow fragments not set 错误
- Replace JSON.NET with ServiceStack.Text in ASP.NET Web API
- 使用Gson解析Json为Map对象探索(上)
- TypeError: the JSON object must be str, not 'TextIOWrapper'
- Android TextView富文本深入探索
- 工具类 json,pojo,text互相转换,解决浏览器对json的兼容问题
- 初步探索fastJson
- 版本号,json解析,安装apk,签名,无标题栏,滚动Textview,自定义组合控件
- ajax开发框架和XMLhttpRequest、responseText、responseXml和JSON的应用
- 遍历对table中input[type='text']的数据封装成json提交到后台处理
- 使用 ServiceStack.Text 序列化 json
- 关于json解析时异常org.json.JSONException: A JSONObject text must begin with '{' at character 1 of {的解决方法