- html:
- <!DOCTYPE html>
- <html>
- <head>
- <Meta charset="UTF-8">
- <title>Insert title here1</title>
- <script type="text/javascript" src="jq.js"></script>
- </head>
- <body>
- <?PHP echo "s";?>
- <script type="text/javascript">
- jQuery(document).ready(function(){
- $.ajax({
- type: "get",async: false,url: "http://www.services.com/dadianlogin/login?username=1111&password=11111",dataType: "jsonp",jsonp: "callback",//传递给请求处理程序或页面的,用以获得jsonp回调函数名的参数名(一般默认为:callback)
- jsonpCallback:"returnjs",//自定义的jsonp回调函数名称,默认为jQuery自动生成的随机函数名,也可以写"?",jQuery会自动为你处理数据
- crossDomain:true,success: function(json){
- alert(json.code);
- },error: function(){
- alert('fail');
- }
- });
- });
- </script>
- </body>
- </html>
应用场景:send传输数据进行登录 services负责验证用户正确与否并生成安全票据 return 获得票据,成功登录