使用api.ajax({},function(ret,err){})给后端传输数据时,后端能够接收到数据,但是前端不能执行回调函数function(ret,err){}。
解决方法:看看按钮是不是放在form表单中的,按钮不能放在表单中。正确格式如下:
<form>
<input type="text" placeholder="用户名" id="username" name="username" />
<input type="password" placeholder="密码不可为空" id="password" name="password" />
</form>
<input type="submit" placeholder="登录" onclick="ajaxpost();" />