Click here to Skip to main content
15,883,975 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear all,
i do have a requirement that to call a webservice method from javascript.
i have written the code as follows.
in .asmx page
[webmethod]
public list<substation> GetsubstationsData()
{
return bcommon.GetSubstationdetails();
}
....
and in aspx page
<select data-bind="options:substationvalues,optionText:'substationname',optionvalue:'substationid',value:selectedsubstationid,optionscaption:'select substation'"/>

in js file
function substationentity(data)
{
var self=this;
self.substationname=ko.observable(data.substationname);
self.substationid=ko.observable(data.substationid);
}
function datamodel()
{
var self=this;
self.substationvalues=ko.observablearray([]);
self.selectedsubstationid=ko.observable("");
fetchsubstationsdata=function(){
$.ajax({
type:'Get',
dataType:'json',
url:'service1.asmx/GetsubstationsData',
success:function(data){
//my binding code;
}
}
});
}
}
and also i want to call addmethod in webservice also, for that should i use type as 'post' in above ajax call....???, the above function is not working for me
it is showing requested url format is not supported...error, how can i achieve this...please help me to solve this.
Posted
Comments
That means your URL is wrong.
pavan_ kumar 10-Jun-15 0:42am    
k,what is the correct format of(url) calling that webservice method.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900