wellsyin
wellsyin
  • 发布:2015-02-05 14:54
  • 更新:2017-12-13 13:16
  • 阅读:3153

ajax方式提交数据,回调函数拿不到返回值

分类:MUI

mui.post("http://192.168.1.81:88/appregister", parm,function(data) {
console.log(data); //why?
},'text')
后台已经获取数据,并插入到数据库中,直接访问url的地址,返回一个文本0.
回调函数没执行,为什么呢?

2015-02-05 14:54 1 条评论 负责人:无 分享
已邀请:
wellsyin

wellsyin (作者)

用zepto的ajax方法,加上同步async:false参数就可以了:
$.ajax({
type: 'POST',
url: 'http://192.168.1.81:88/appregister',
// data to be added to query string:
data:param,
// type of data we are expecting in return:
dataType: 'text',
timeout: 3000,
context: $('body'),
async:false,
success: function(data){
alert(data);
},
error: function(xhr, type){
alert('Ajax error!')
}
})
}
=====================
mui是怎么解决的呢?

DCloud_UNI_FXY

DCloud_UNI_FXY

用mui.ajax,然后配置error的回调,打印一下error看看是报的什么错误

7***@qq.com

7***@qq.com - 90后

你的出来没 能看下不

该问题目前已经被锁定, 无法添加新回复

  • 标题 / 粗斜体
  • 代码片段
  • 超链接 / 图片 / 视频
  • 列表 / 引用

文章内容较多时,可以用标题分段 :

## 大标题 
### 小标题

斜体 / 粗体 :

**粗体** 
*斜体*
***粗斜体***

代码片段 :

``` javascript
代码片段
```

超链接 :

[链接文字](链接地址) 例: [百度](http://www.baidu.com)

图片 :

![图片说明](图片地址) 例: ![百度logo](http://www.baidu.com/img/bdlogo.gif)

视频 :

!![视频说明](视频地址) 例: !![优酷视频](http://youku.com)

有序列表 :

1. 123
2. 123
3. 123

无序列表 :

- 123
- 123
- 123

引用 : ( 双回车后结束引用 )

> 引用内容
引用内容
引用内容