Hope this is a pretty simple question. Forgive my ignorance, but I'm mostly a PHP / Zend developer, so I'm struggling a bit with C # and Visual Studio with the json / ajax problem. Is there something obvious that I'm missing? Any help would be appreciated. Should I look at List<> ?
Here is the error I get when I run the javascript ajax function: Msgstr "Unknown getwidgets web method."
I have a C # dataset that I run through a JSON converter. This works well and returns my data in a JSON string.
private widgetsBL widgetsBLObject = new widgetsBL(); [WebMethod] public String getwidgets() { DataSet results = new DataSet(); results = widgetsBLObject.selectTheWidgets(); string jsresults = MyClassLibrary.JqueryTools.GetJSONString(results.Tables[0]); return jsresults; }
Here is jsresults:
{"Table" : [ {"widgetid" : "1","widgetname" : "gizmo1000","widgetdescription" : "very cool widget"}, {"widgetid" : "2","widgetname" : "gizmo2000","widgetdescription" : "decent widget"}, {"widgetid" : "3","widgetname" : "gizmo3000","widgetdescription" : "terrible widget"} ]}
My Javascript call:
$.ajax({ type: "POST", url: "my.aspx/getwidgets", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) {
source share