I am trying to call a C# method from my javascript code that when the user presses a button it updates the query variable and gets back a new table for those dates. but my javascript dosnt call the C# method.
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 () {}
})
});
});
The C# function it calls is this one:
[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
}
And this is the buttons html:
<dic id="trLeftArrow" class="icon-circle-arrow-left" style=" -webkit-text-stroke: 1px black; bottom:0px; display:inline-block;font-size: 40px; color: rgb(125, 180, 245)"></div>
I know both updateUrlVar and loadTable work. But the javascript dosnt call the backWeek function even though it captures the onClick event for the button
I tried returning a json from the backWeek function but it didnt change anything because the function isnt called
2