zoukankan      html  css  js  c++  java
  • .net jquery ajax应用(前端)

     //一般处理程序,GET方式提交(data:要传送的数据键值对)     
                jQuery.ajax(
                                                    { type: 'GET',
                                                        url: 'GradeHandler.ashx?startCount&starDescri',
                                                        data: { startCount: startCount, starDescri: starDescri },                  //(对)
                                                        // data: '{ startCount:"' + startCount + '",starDescri:"' + starDescri + '"}', (错)             
                                                        contentType: "application/json; charset=utf-8",
                                                        dataType: 'json',
                                                        success: function (result) {
                                                            if (result)//返回true
                                                                alert('评分成功!');
                                                            else
                                                                alert('评分失败' + result);
                                                        },
                                                        error: function () {
                                                            alert("ajax调用错误");
                                                        }
                                                    }
                                                        );

       //一般处理程序,POST方式提交(data:要传送的数据键值对)
                jQuery.ajax(
                                    { type: 'POST',
                                        url: 'GradeHandler.ashx',
                                        data: { startCount: startCount, starDescri: starDescri },      //(对)
                                        //  data: '{ startCount:"' + startCount + '",starDescri:"' + starDescri + '"}',  //(错)
                                        //  contentType: "application/json; charset=utf-8",            //不能添加该参数
                                        dataType: 'json',
                                        success: function (result) {
                                            if (result)//返回true
                                                alert('评分成功!');
                                            else
                                                alert('评分失败' + result);
                                        },
                                        error: function () {
                                            alert("ajax调用错误");
                                        }
                                    }
                                        );

               /*
                jQuery调用WebService的方法(只能发送post方式的请求);
                返回json格式的数据时,需设置contentType为application/json (data要用Json的字符串格式传入)
                返回的数据是以字母d为键值的json对象。
                */
                jQuery.ajax(
                                                { type: 'POST',
                                                    url: 'WebService/GradeWebService.asmx/UserGrade',
                                                    data: '{ count:"' + startCount + '",descri:"' + starDescri + '"}',     //(对)
                                                    // data: { count: startCount, descri: starDescri },                        //(错)       
                                                    contentType: "application/json; charset=utf-8",
                                                    dataType: 'json',
                                                    success: function (result) {
                                                        if (result.d)//返回true
                                                            alert('评分成功!' + result.d);
                                                        else
                                                            alert('评分失败' + result.d);
                                                    },
                                                    error: function () {
                                                        alert("ajax调用错误");
                                                    }
                                                }
                                                    );

  • 相关阅读:
    sklearn中禁止输出ConvergenceWarning:
    sklearn里训练集和测试集的分割
    sklearn模型的保存与加载使用
    django项目成功启动,但views里代码未执行
    使用sklearn对iris数据集做基本的训练和预测
    unrecognized option '--high-entropy-va'
    快速下载Mingw(不使用sourceforge.net)
    cc1.exe: sorry, unimplemented: 64-bit mode not compiled in
    GoLand里Go Module模式下import自定义包
    GoLand生成可执行文件(Windows、Linux)
  • 原文地址:https://www.cnblogs.com/xiaowei-blog/p/4293076.html
Copyright © 2011-2022 走看看