jquery jsonp 跨域请求实例
来源:互联网 发布:linux查看文件大小 编辑:程序博客网 时间:2024/04/29 08:06
利用jquery php来实现js的跨域请求
html代码:
- <html>
- <script src="jquery.min.js" type="text/javascript" ></script>
- <script>
- function pushstar(){
- var reval= '';
- var host = 'www.xxx.com';
- //editor.sync();
- var star= document.getElementById('content');
- value ='这里设置内容';
- $.ajax({
- async:false,
- type: 'GET',
- url: "http://" + host +"/index.php" ,
- data:{param:value} ,
- jsonpCallback:"callbak",
- dataType:'jsonp',
- jsonp: 'callbak',
- error:function(request){
- //var jsona = $.parseJSON(msg);
- alert('fail');
- },
- success:function(msg){
- if(msg[0] == 1){
- alert(msg[1]);
- }else{
- alert('fail');
- }
- },
- });
- }
- </script>
- 点击<input type="button" onclick="pushstar()">
- </html>
<html><script src="jquery.min.js" type="text/javascript" ></script><script>function pushstar(){var reval= '';var host = 'www.xxx.com';//editor.sync();var star= document.getElementById('content');value ='这里设置内容';$.ajax({async:false,type: 'GET',url: "http://" + host +"/index.php" ,data:{param:value} ,jsonpCallback:"callbak",dataType:'jsonp',jsonp: 'callbak', error:function(request){//var jsona = $.parseJSON(msg);alert('fail');},success:function(msg){if(msg[0] == 1){alert(msg[1]);}else{alert('fail');}},});}</script>点击<input type="button" onclick="pushstar()"></html>
index.php代码:
- <?php
- /*
- *回调文件
- */
- $arr[] =1;
- $arr[] ='cuccess';
- echo 'callbak('.json_encode($arr).')';exit;
- ?>
0 0
- jquery jsonp 跨域请求实例
- jsonp 跨域请求实例
- jsonp 跨域请求实例
- jquery jsonp跨域请求
- jquery jsonp 跨域请求
- jquery jsonp 跨域请求
- ajax跨域请求--jsonp实例
- ajax jsonp 跨域请求访问实例
- JS JSONP跨域请求实例详解
- Ajax jsonp跨域请求实例
- ajax jsonp 跨域请求访问实例
- .net jquery jsonp跨域请求
- jquery+jsonp跨域请求注意事项
- jquery使用jsonp跨域请求问题
- jQuery ajax jsonp实现跨域请求
- JQuery利用JSONP实现跨域请求
- jQuery ajax jsonp实现跨域请求
- JSONP jQuery Ajax 跨域请求
- Python Learning Note
- EASYUI DATAGRID 多列复选框CheckBox
- 字符串匹配的Boyer-Moore算法
- MFC - 屏蔽回车和ESC键
- 使用java进行文件编码转换
- jquery jsonp 跨域请求实例
- Easy BST
- thrift实现一个C++实例遇到的问题
- HDU - 1846 - Brave Game (巴什博弈)
- JSON解析详解
- Apache配置虚拟目录
- 仿《文明》游戏制作日志2
- 求出在字符串S中包含字符串T的最小字符串
- Android开发之重要组件