javascript - Error calling wcf service by ajax -
iwent run simple wcf method using ajax in html page test doesn't run @ , idont know whats problem
![error message][1]
icustomerservice page
[operationcontract] [webinvoke(method = "post", responseformat = webmessageformat.json)] string gettest();
service.svc page
[aspnetcompatibilityrequirements(requirementsmode = aspnetcompatibilityrequirementsmode.allowed)] public class service1 : icustomerservice { public string gettest() { return "okkkkkkkk"; }
here html page
> > <title></title> > <script type="text/javascript"></script> > <script type="text/javascript"src="scripts/jquery-2.1.1.min.js"></script> > <script type="text/javascript" src="scripts/jquery-2.1.1.intellisense.js"></script> > <script type="text/javascript" src="scripts/jquery-2.1.1.js"></script> > <script type="text/javascript" src="scripts/jquery.unobtrusive-ajax.js"></script> > <script type="text/javascript" src="scripts/jquery.unobtrusive-ajax.min.js"></script> > > > <script type="text/javascript"> > var url = 'http://localhost:43315/service1.svc/' > > function getproducts() { > > var response; > > $.ajax({ > async: true, > type: 'post', > url: url + 'gettest', > contenttype: 'application/json; charset=utf-8', > datatype: 'json', > success: function () { > alert("yahooooooooo"); > }, > > error: function (e) { > alert("error : " + e.statustext); > } > }); > } > >
here web.config page
<system.servicemodel> <behaviors> <servicebehaviors> <behavior name="service1behavior"> <servicemetadata httpgetenabled="true" httpsgetenabled="true"/> <servicedebug includeexceptiondetailinfaults="true"/> </behavior> </servicebehaviors> <endpointbehaviors> <behavior name="webbehavior"> <enablewebscript/> </behavior> </endpointbehaviors> </behaviors> <services> <service behaviorconfiguration="service1behavior" name="wcfservice1.service1"> <endpoint address="" binding="basichttpbinding" contract="wcfservice1.iservice1" /> <endpoint address="web" binding="webhttpbinding" contract="wcfservice1.iservice1" behaviorconfiguration="webbehavior" /> </service> </services> <protocolmapping> <add binding="basichttpsbinding" scheme="https" /> </protocolmapping> <servicehostingenvironment aspnetcompatibilityenabled="true" multiplesitebindingsenabled="true" /> </system.servicemodel>
is url correct? think port might have changed. host service in iis try.
Comments
Post a Comment