Hi i am trying to create dynamic html elements on ajax success response but getting a facing different kind of problem.
In browser console i can see the success result:
[{"ResponseTime":"13/6/2019 24:51","TicketId":0,"UserId":"ricky.global9@gmail.com","Subject":"Domain problem","Department":"Sales","Description":"Content 2","FileId":"NULL","ResponseType":null},{"ResponseTime":"13/6/2019 23:51","TicketId":0,"UserId":"ricky.global9@gmail.com","Subject":"_Payment_issue","Department":"Support","Description":"Content 1","FileId":"NULL","ResponseType":null}]{"d":null}
Here
{"d":null}
is suspicious...
But ajax also triggers error function "undefined"
Here is my ajax
<pre>
var tid = '2723021';
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "../../Service.asmx/GetTicketDetails",
data: "{ TicketID: '" + tid + "'}",
dataType: "json",
success: function (data) {
var SignalTable = $('#ticketDetails');
SignalTable.empty();
$(data).each(function (index, sigs) {
SignalTable.append('<p>'
+ sigs.ResponseTime
+ '</p><p>' + sigs.UserId
+ '</p><p> ' + sigs.Subject
+ '</p ><p>' + sigs.Department
+ '</p><p>' + sigs.Description
+ '</p><p>' + sigs.FileId + '</p><p>');
});
},
error: function (err) {
alert('Err ' + err);
}
});
The webmethod
<pre>
public void GetTicketDetails(string TicketID)
{
List<SupportTicket> SideTickets = new List<SupportTicket>();
string CS = ConfigurationManager.ConnectionStrings["iqCon"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
SqlCommand cmd = new SqlCommand("procSidebarTicketDetails", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Ticketid", TicketID);
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
SupportTicket tickets = new SupportTicket();
tickets.ResponseTime = rdr["Response_time"].ToString();
tickets.UserId = rdr["User_email"].ToString();
tickets.Subject = rdr["Support_subject"].ToString();
tickets.Department = rdr["Support_department"].ToString();
tickets.Description = rdr["Support_description"].ToString();
tickets.FileId = rdr["File_id"].ToString();
SideTickets.Add(tickets);
}
}
JavaScriptSerializer js = new JavaScriptSerializer();
Context.Response.Write(js.Serialize(SideTickets));
}
And the class object
public class SupportTicket
{
public string ResponseTime { get; set; }
public int TicketId { get; set; }
public string UserId { get; set; }
public string Subject { get; set; }
public string Department { get; set; }
public string Description { get; set; }
public string FileId { get; set; }
public string ResponseType { get; set; }
}
What I have tried:
I tried all possibilities from my end but couldn't find where is am doing wrong.