JSONP跨域提交表单
2015-05-03 19:08
190 查看
JSONP跨域提交表单
分类:ajax+jquery+js系列
php+mysql系列文摘 2013-07-06 15:22
1422人阅读 评论(7)
收藏
举报
test.html页面代码:
[html]
view plaincopy
<!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]
view plaincopy
<?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;
?>
相关文章推荐
- jquery Ajax 通过jsonp的方式跨域提交表单
- C#使用jsonp进行跨域提交表单
- JSONP跨域提交表单
- Jquery Jsonp跨域提交表单获取返回数据
- 表单ajax提交不跳转,清空input框值以及php跨域请求数据总结
- jquery mobile + html5 手机app表单跨域提交实例(手机app开发html5 juqery moblie phonegap系列一)
- jquery下异步提交表单 异步跨域提交表单
- 跨域表单提交状态的变相判断代码
- 跨域提交表单攻击
- 使用jQuery实现-跨域-提交表单数据
- 使用jQuery实现跨域提交表单数据
- ajax 跨域封装 JSONP方式 默认还是GET提交请求
- jQuery ajax异步跨域提交表单实例解析
- 跨域小结(为什么form表单提交没有跨域问题,但ajax提交有跨域问题)
- php实现跨域提交form表单的方法【2种方法】
- 解决Jquery ajax的post get跨域提交表单
- 今天介绍两种跨域提交form表单的方法
- PHP防止跨域提交表单
- php实现跨域提交form表单的方法【2种方法】
- ***使用jQuery实现跨域提交表单数据