Here is my jquery code
var ajaxUrl = "AjaxCallHandler.aspx";
function _init_Chart() {
$.ajax({
type: "GET", //GET or POST or PUT or DELETE verb
url: ajaxUrl, // Location of the service
data: "OpCode=GetCallAverageReportForGraph&Parms=DeptId^17~Month^10~Year^2012", //Data sent to server
contentType: "", // content type sent to server
dataType: "string", //Expected data format from server
processdata: true, //True or False
success: function (responseString) {//On Successful service call
alert(responseString);
}
});
return false;
}
Here is my c# code
protected void Page_Load(object sender, EventArgs e)
{
string responseMessage = "";
string status = "SUCCESS";
try
{
if (Request.QueryString["OpCode"] == null)
{
throw new Exception("Invalid Request, OpCode missing.");
}
string operationRequested = Request.QueryString["OpCode"];
string Params = Request.QueryString["Parms"];
switch (operationRequested)
{
case "GetCallAverageReportForGraph":
responseMessage = GetCallAverageReportForGraph(Params);
break;
case "GetCallAverageReportDetails":
responseMessage = GetCallAverageReportDetails(Params);
break;
}
}
catch (Exception exp)
{
status = "EXCEPTION";
responseMessage = exp.Message;
}
Response.ClearContent();
Response.ClearHeaders();
Response.Write(responseMessage);
}
I tried putting a breakpoint in the c# code. It is writing Response.Write from c# code but I’m unable to receive the response in jquery code. Can any one point out the issue?
Change the data type string to html or leave it empty for default type
Refer http://api.jquery.com/jQuery.ajax/