//提交动作已经完成,但是没有发挥响应数据,不知道哪里设置有问题?
var arr = ['http://fight.pet.qq.com/cgi-bin/petpk?cmd=fight&puin=654159722']
var xhr = new XMLHttpRequest();
$('#btn').click(function(){
xhr.open( "GET", arr[0], true );
xhr.withCredentials = true; // 支持跨域发送cookies
xhr.setRequestHeader('Accept','text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
xhr.send(); // 发送请求
})
==通过firebug 重新发送就没问题
==>整个对象的数据
1.可能后台没有获取到数据
2.如果后台有数据,那就是ajax没有接住数据
这个原因很多,,看下前后端的报错就知道了
var arr = ['http://fight.pet.qq.com/cgi-bin/petpk?cmd=fight&puin=654159722']
var xhr = new XMLHttpRequest();
$('#btn').click(function(){
xhr.open( "GET", arr[0], true );
xhr.withCredentials = true; // 支持跨域发送cookies
xhr.setRequestHeader('Accept','text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
xhr.send(); // 发送请求
})
也对请求头部 补充了一些参数, 结果还是一样
firebug 重新发送就没问题 。-响应数据也有了。
var arr = ['http://fight.pet.qq.com/cgi-bin/petpk?cmd=fight&puin=654159722']
var xhr = new XMLHttpRequest();
$('#btn').click(function(){
xhr.open( "GET", arr[0], true );
xhr.withCredentials = true; // 支持跨域发送cookies
xhr.setRequestHeader('Accept','text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
xhr.send(); // 发送请求
})
var arr = ['http://fight.pet.qq.com/cgi-bin/petpk?cmd=fight&puin=654159722']
var xhr = new XMLHttpRequest();
$('#btn').click(function(){
xhr.open( "GET", arr[0], true );
xhr.withCredentials = true; // 支持跨域发送cookies
xhr.setRequestHeader('Accept','text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
xhr.send(); // 发送请求
})
ajax异步交互不得接收一下返回的值
看下后台返回的状态码,这个原生+Jquery也是比较6.