I have an asp web application in visual studio 2008. i have jquery-1.10.2.js in a Folder - JavaScriptBase
files in solution 1. Dashboard.aspx 2. JavaScripts/Dashboard.js
I have a jQuery Tab
<li><a href="#tabs-1" id="tab1" runat="server" onclick="GetData(0)">Today</a></li>
<li><a href="#tabs-2" id="tab2" runat="server" onclick="GetData(7)">1-7 days</a></li>
<li><a href="#tabs-3" id="tab3" runat="server" onclick="GetData(30)">30 days</a></li>
<li><a href="#tabs-4" id="tab4" runat="server" onclick="GetData(60)">60 days</a></li>
<li><a href="#tabs-5" id="tab5" runat="server" onclick="GetData(90)">90 days</a></li>
<li><a href="#tabs-6" id="tab6" runat="server" onclick="GetData(180)">180 days</a></li>
The GetData() function is inside Dashboard.js in a folder- JavaScripts
function GetData(ky)
{
var params = "{'days' : '" + ky + "'}"; // if no params need to use "{}"
alert(params);
$.ajax({
url: "Dashboard.aspx/getDataByDate",
type: 'POST',
data: params,
contentType: "application/json; charset=utf-8",
dataType: 'json',
success: function (data, status) {
loadSuccess(data, status);
},
error: function () {
alert("Oops! It's an Error");
}
});
return false;
}
In my Code behind
public string getDataByDate(string days)
{
DataSet ds = new DataSet();
ds = getPatientVisitCount(DateTime.Today.ToString(), DateTime.Today.ToString()));
return ds.GetXml();
}
when i call the function it always go to error function.
How to call the function in the code behind from js file. please help...
EDIT 1
I change my cs code according to Grundy suggestion
[WebMethod()]
public string getDataByDate(string days)
{
DataSet ds = new DataSet();
ds = getPatientVisitCount(DateTime.Today.ToString(), DateTime.Today.ToString()));
return ds.GetXml();
}
still not getting..
error:function(xhr, textstatus, errorthrown)- there are arguments here you could be using to debug.index.htmlor whichever item the javascript is loaded into