Featured post
issue with singleton method in calling WCF using JQuery -
i created bare simple method, increments number 1 , returns value.
[servicecontract] public interface icalc { [operationcontract] [webget(uritemplate = "getnumber")] int getnextnumber();
service class:
[servicebehavior(instancecontextmode = instancecontextmode.single)] public class calculator : icalc { int = 1; public int getnextnumber() {return i++; } }
the service hosted using webhttpbinding , works when opened browser. example, when browse http://localhost:8083/calc/getnumber ,
<int xmlns="http://schemas.microsoft.com/2003/10/serialization/">1</int>
every time refresh, value keeps incrementing 1 in xml response (as expected due singleton behavior)
problem
when call same service using jquery as:
$.ajax( { type: "get", url: "http://localhost:8083/calc/getnumber", data: "", contenttype: "application/html", processdata: true, success: function (msg) { alertresult(alert(msg.childnodes[0].xml)) } } );
i keep getting same (latest) number , debugger not invoked @ service.
what not understanding is: if method not getting called using jquery, how getting valid output , if method called why increment not taking place (which works if invoke service hitting service url directly browse)r???
thanks!
try adding cache: false
properties of ajax request force browser request url everytime otherwise every sane browser cache response request url doesn't change.
- Get link
- X
- Other Apps
Comments
Post a Comment