weex
weex copied to clipboard
[bug]同样的网络请求在浏览器上请求不成功,集成到iOS上可以请求成功
在mac上用火狐浏览器打开时请求失败,但集成到iOS中去可以请求成功,在weexPlayground中也能成功。不知是什么原因。代码如下:
requestData:function(sd){
var self = this
var stream = require('@weex-module/stream')
var modal = require('@weex-module/modal')
var GET_URL = 'http://192.168.5.56:8383/mkt-back/productManagement/findCapitalReceipts?staffId='+sd
self.toast('数据加载中...')
stream.fetch({
method: 'GET',
url: GET_URL,
type: 'json'
}, function(ret) {
if (typeof ret == 'string') {
ret = JSON.parse(ret)
}
if (!ret.ok) {
modal.alert({
message: '获取数据失败',
okTitle: '好'
})
} else {
if (typeof ret.data == 'string') {
ret.data = JSON.parse(ret.data)
}
}
},function(response){
});
},
有什么报错信息?我估计和跨域有关。
恩,我估计也是跨域,哈哈
@Hanks10100 @cooliean ,浏览器中报如下错误:
[h5-render] unexpected error in _xhr for 'fetch' API error { target: XMLHttpRequest, isTrusted: true, lengthComputable: false, loaded: 0, total: 0, currentTarget: XMLHttpRequest, eventPhase: 2, bubbles: false, cancelable: false, defaultPrevented: false, timeStamp: 1479880155863948 } weex.js:20523:6
_xhr/xhr.onerror
跨域问题怎么解决?
我的WEEX HTML5已经更新到0.4.0 START WEEX HTML5: 0.4.0 Build 20161019 但是我使用JSONP跨域还是会报错Unexpected token,请问是怎么回事
可能是你服务器端配置的 jsonp callback 名字不对,服务器是从 callback 这个参数里取回调函数的名称么?@1459416736