当ajax调用webmethod时,如何加快速度 [英] How do I make faster when ajax calls webmethod

查看:70
本文介绍了当ajax调用webmethod时,如何加快速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[Play.aspx]
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
.....
viewvideo(videoid)
.......
</asp>
[Video.js]
function viewvideo(videoid) 
{
    varVideoid = videoid;
    $("#video").empty();
    var data = Ajax("../Ajax/Webmethod.aspx/getviewvideo", { videoid: videoid });
}
[function.js]
function Ajax(url, _data) {
    var obj;
    $.ajax({
        type: "post",
        url: url,
        data: JSON.stringify(_data),
        async: false,
        contentType: "application/json; charset=utf-8",
        datatype: "json",
        success: function (data) {
            obj = $.parseJSON(data.d);
        },
        error: function (xhr, status, error) {
            alert("Some Error");
        }
    });
    return obj;
}
[Webmethod.aspx.cs]
 [WebMethod]
    public static string getviewvideo(string videoid)
    {
        databasesss db = new databasesss();
        JavaScriptSerializer js = new JavaScriptSerializer();
.........................
        }
        return js.Serialize(v);
    }



当ajax调用Webmethod时,会出现速度问题。

我的代码出了什么问题,或者我应该怎么做检查?

任何评论都会有帮助

谢谢



我尝试过:



我试过用< asp:hiddenfield>但是有很多东西需要编辑,所以我正在寻找另一种方式


Hi , When ajax call Webmethod, there is speed issue.
What is wrong with my code or what should I check?
Any comment would be helpful
Thank you

What I have tried:

I have tried to use <asp:hiddenfield> but there are many things to edit so I am looking for another way

推荐答案

(#video)。empty();
var data = Ajax(../ Ajax / Webmethod.aspx / getviewvideo,{videoid:videoid});
}
[function.js]
函数Ajax(url,_data){
var obj;
("#video").empty(); var data = Ajax("../Ajax/Webmethod.aspx/getviewvideo", { videoid: videoid }); } [function.js] function Ajax(url, _data) { var obj;


.ajax({
类型:post,
url:url,
数据:JSON.stringify(_data),
async:false,
contentType:application / json; charset = utf-8,
数据类型:json,
成功:函数(数据){
obj =
.ajax({ type: "post", url: url, data: JSON.stringify(_data), async: false, contentType: "application/json; charset=utf-8", datatype: "json", success: function (data) { obj =


.parseJSON(data.d) ;
},
错误:函数(xhr,状态,错误){
alert(Some Error);
}
});
return obj;
}
[Webmethod.aspx.cs]
[WebMethod]
public static string getviewvideo(string videoid)
{
databasesss db = new databasesss( );
JavaScriptSerializer js = new JavaScriptSerializer();
.........................
}
返回js.Serialize(v);
}
.parseJSON(data.d); }, error: function (xhr, status, error) { alert("Some Error"); } }); return obj; } [Webmethod.aspx.cs] [WebMethod] public static string getviewvideo(string videoid) { databasesss db = new databasesss(); JavaScriptSerializer js = new JavaScriptSerializer(); ......................... } return js.Serialize(v); }



当ajax调用Webmethod时,会出现速度问题。

我的代码出了什么问题,或者我应该怎么做检查?

任何评论都会有帮助

谢谢



我尝试过:



我试过用< asp:hiddenfield>但是有很多东西要编辑,所以我正在寻找另一种方式


Hi , When ajax call Webmethod, there is speed issue.
What is wrong with my code or what should I check?
Any comment would be helpful
Thank you

What I have tried:

I have tried to use <asp:hiddenfield> but there are many things to edit so I am looking for another way


这篇关于当ajax调用webmethod时,如何加快速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆