I am trying to create an update linq query & I generate table using jQuery so after update how do I save changes to data in the table?
[WebMethod] public static string updateselect_data(int ServiceID, string frequency, string Freq_Du, string Freq_Mil) { try { Track_Data track = new Track_Data(); DataTable dt = new DataTable(); var update = from p in track.Serv where p.ServiceID == ServiceID select p; foreach (var q_update in update) { q_update.frequency= frequency; q_update.Freq_Du= Freq_Du; q_update.Freq_Mil= Freq_Mil; } HttpContext.Current.Session["SID"] = ServiceID; HttpContext.Current.Session["frequency"] = frequency; HttpContext.Current.Session["Freq_Du"] = Freq_Du; HttpContext.Current.Session["Freq_Mil"] = Freq_Mil; try { track.SaveChanges(); } catch (Exception e) { throw new Exception(); } return new JavaScriptSerializer().Serialize(update); } catch { throw new Exception(); }
JQUERY CODE
<script type="text/javascript"> debugger; $(function () { $('[ID*=btn_update]').on('click', function () { var ServiceID = '<%=Session["SID"]%>'; var frequency='<%=Session["frequency"]%>'; var Freq_Du = '<%=Session["Freq_Dur"]%>'; var Freq_Mil = '<%=Session["Freq_Mil"]%>'; debugger; var obj = {}; obj.ServiceID = ServiceID; obj.frequency = frequency; obj.Freq_Dur= Freq_Du; obj.Freq_Mil = Freq_Mil; updatedata(obj); }); }); function updatedata(obj){ $.ajax({ type: "POST", url: "Maintenance.aspx/updateselect_data", contentType: "application/json;charset=utf-8", data:"{'SID:'"+ obj.ServiceID+"','frequency:'"+obj.frequency+"','Freq_Du:'"+obj.Freq_Du+"','Freq_Mil:'"+obj.Freq_Mil+"'}", dataType: "json", success:function(result) { debugger; var up = JSON.parse(result.d).response; } }); } </script>
i create table throgh jquery now first i want to update and want to check in console now when i do above code this show error s
and this show an error Invalid object passed in JSON