• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
皇图霸业谈笑间
更高、更快、更强
博客园    首页    新随笔    联系   管理    订阅  订阅
关于IOS和ANDROID上面使用AJAX的POST小细节

这个小细节花了我30分钟时间排查

哎.....

 

总结:

IOS和ANDROID没有像浏览器支持的那么好,在POST数据的时候,数据体DATA格式中,不能让参数用class命名

错误示范:

 

    $.ajax({
        type: "post",
        url: "http://www.cnblogs.com/../iPhoneReader/GetUserControlHtml.ashx",
        data: { action: this.Action, sort: this.SortType, pi: this.PageIndex, ps: this.PageSize,class:this.ClassType },
        dataType: "html",
        success: function(result) {
            $(contentID).html(result);
            if (flag) {
                resSecurity();
            }
        }
    });

 

注意这里的最后一个参数:  

class:this.ClassType

这样命名是有问题的,IOS和ANDROID是不支持这样请求的

最后调整为:

    $.ajax({
        type: "post",
        url: "http://www.cnblogs.com/../iPhoneReader/GetUserControlHtml.ashx",
        data: { action: this.Action, sort: this.SortType, pi: this.PageIndex, ps: this.PageSize,classtype:this.ClassType },
        dataType: "html",
        success: function(result) {
            $(contentID).html(result);
            if (flag) {
                resSecurity();
            }
        }
    });

 

posted on 2011-11-30 15:24  布颜书  阅读(11208)  评论(1)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3