JSONP跨域提交表单
2013-07-06 15:22
197 查看
test.html页面代码:
jsonp.php 文件代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Untitled Page</title> <script src="/inc/ajax/jquery.js" type="text/javascript"></script> <script type="text/javascript"> jQuery(document).ready(function(){ $.ajax({ type: "GET", async: false, url:"http://www.abc.com/jsonp.php", dataType: "jsonp", data:"uname=jolin12&upass=a123456&mn1=100&mn2=200", jsonp: "callback",//传递给请求处理程序或页面的,用以获得jsonp回调函数名的参数名(一般默认为:callback) jsonpCallback:"flightHandler",//自定义的jsonp回调函数名称,默认为jQuery自动生成的随机函数名,也可以写"?",jQuery会自动为你处理数据 success: function(json){ alert('用户名是: ' + json.uname + ' 登陆密码: ' + json.upass + ',费用合计:'+json.monney+'元。'); }, error: function(){ alert("fail"); } }); }); </script> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> </head> <body> </body> </html>
jsonp.php 文件代码:
<?php $callback = $_GET["callback"]; $uname = $_GET["uname"]; $upass = $_GET["upass"]; $mn1 = $_GET["mn1"]; $mn2 = $_GET["mn2"]; $total =($mn1+$mn2); $a = array( 'uname'=>$uname, 'upass'=>$upass, 'monney'=>$total, ); $result = json_encode($a); echo "flightHandler($result)"; exit; ?>
相关文章推荐
- JSONP跨域提交表单
- Jquery Jsonp跨域提交表单获取返回数据
- jquery Ajax 通过jsonp的方式跨域提交表单
- C#使用jsonp进行跨域提交表单
- PHP防止跨域提交表单
- PHP防止跨域提交表单
- http模拟from表单提交,进行跨域请求和上传资源
- PHP防止跨域提交表单
- 脱离jsonp,如何跨域读取、提交数据 da宗熊
- ajax提交form表单+跨域
- JS工具函数封装:使用隐藏iframe实现跨域表单提交
- 脱离jsonp,如何跨域读取、提交数据
- Ajax跨域提交JSON和JSONP
- js跨域提交表单【详细教程,包解决】
- curl 模拟表单提交文件 跨域跨服务器上传文件
- 防止 本地 提交 表单 跨域
- 表单跨域提交
- 跨域表单提交状态的变相判断代码
- jquery mobile + html5 手机app表单跨域提交实例(手机app开发html5 juqery moblie phonegap系列一)
- 表单ajax提交不跳转,清空input框值以及php跨域请求数据总结