javascript - display data from database in angularjs and json -
i trying display data database in angularjs using webservice geting error[object object] while retriving data
my web method is:
<webmethod()> _ <scriptmethod(responseformat:=responseformat.json)> _ public function getdata() string dim strcon sqlconnection = new sqlconnection("data source=pc12\sql2;initial catalog=testdata;user id=abc;password=xxxx; timeout=0;") dim dt datatable = new datatable dim da sqldataadapter dim cmd sqlcommand = new sqlcommand("select * user", strcon) strcon.open() da = new sqldataadapter(cmd) da.fill(dt) dim serializer new system.web.script.serialization.javascriptserializer() dim rows new list(of dictionary(of string, object))() dim row dictionary(of string, object) each dr datarow in dt.rows row = new dictionary(of string, object)() each col datacolumn in dt.columns row.add(col.columnname, dr(col)) next rows.add(row) next return serializer.serialize(rows) end function my javascript call webservice:-
$(document).ready(function () { $.ajax({ type: 'post', url: 'webservice1.asmx/getdata', data: '{}', contenttype: 'application/json; charset=utf-8', datatype: 'json', success: function (data) { alert("result: " + data); }, error: function (xmlhttprequest, textstatus, errorthrown) { alert("error: " + errorthrown + xmlhttprequest + textstatus); } }); });
got solution
i haven't added attribute in web service.
only web services attribute on class definition can called script.
after adding got data.
Comments
Post a Comment