Javascript
Код: Выделить всё
$(function () {
$('.icon-circle-arrow-left').live("click", function(){
$a.ajax({
type: "POST",
url: "TrMainPage.aspx/backWeek",
contentType: "application/json; charset=utf-8",
data: "{}",
dataType: "json",
succes: function(res) {
var tbl = document.getElemenById("weekTbl");
tbl.innerHTML = res;
},
error: function () {}
})
});
});
Код: Выделить всё
[WebMethod]
[ScriptMethod]
public static string backWeek()
{
string fullDateString = HttpContext.Current.Request.QueryString.ToString().Replace("d1=","").ToString().Replace('-','/');
DateTime startOfWeek;
if (DateTime.TryParse(fullDateString,out startOfWeek))
{
String.format("{0:d/M/yyyy}" startOfWeek);
}
else {
startOfWeek = DateTime.parse("1/1/2010");
}
updateUrlVar(startOfWeek.AddDays(-7));
//updates the query variable to the new start of week date
return loadTable(); //returns a html table with the right info
}
Код: Выделить всё
Я попробовал вернуть json из функции backWeek, но это ничего не изменило, потому что функция не вызывается
п>
Подробнее здесь: https://stackoverflow.com/questions/792 ... p-function
Мобильная версия