我正在做asp.net中的jquery ajax調用,我從數據庫中獲取一些值在文本框中,並基於它我正在jquery progressbar。 它在文本框中獲取值,但它並沒有取得進度條的第一次值,我不得不重新加載頁面進度條的值。
下面是我的代碼jquery在asp.net中的Ajax調用進度條更新
$(function() {
GetValue();
var l_count= parseInt($("#txtcount").val());
$("#sliderlicense").progressbar({
max: 100,
value: l_count
});
});
function GetValue() {
$.ajax({
type: "POST",
url: "MyPage.aspx/GetCount", //url to point your webmethod
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (Result) {
$("#txtcount").val(Result.d);
},
error: function() { alert('error'); }
});
}
[System.Web.Services.WebMethod()]
public static string GetCount()
{
//Get values from DB and return it
}
我也試圖與的document.ready,但沒有運氣,我應該用哪個事件的jQuery做的第一次我的進度條。
由於它的工作完美:) –