Thanks for the info. How exactly are you writing directly to the response using WCF? My IIS hosted WCF service is basically just acting like a proxy to a windows hosted WCF service, so they both use the same contract, but the IIS hosted service is a REST based service. Is there a way to maintain this uniformity of contracts, while writing directly to the response of the IIS service?
On Oct 23, 8:22 am, tenaciousd <[EMAIL PROTECTED]> wrote: > If you're going to do cross-domain calls you can't do a POST, only a > GET. I think even if you specify POST as your type jQuery will > convert it to a GET if your datatype is jsonp (check their doc but I'm > pretty sure that's the case). > > As for WCF the key is just making sure that you wrap your return in > the callback method and write it to the Response. In other words, you > can't simply have a WCF endpoint that returns a json-formatted > object. Instead you need to write something like > "callbackMethodName(" + yourJSONObject + ");" to the Response. Once > you've done this jQuery will execute the callback call, in which it > will do an eval() on yourJSONObject and then call the success method, > passing it the JSON object in the data parameter. At that point you > will have dot notation on your JSON object. > > On Oct 22, 7:31 pm, RWF <[EMAIL PROTECTED]> wrote: > > > I am using WCF too, have you done projects that require an $.ajax POST > > request to a WCF service cross site? If you have, how did come up > > with a server proxy to allow for cross site communication? > > > On Oct 10, 2:01 pm, tenaciousd <[EMAIL PROTECTED]> wrote: > > > > Nevermind. The fundamental issue was that the json object wrapped in > > > the callback name does, in fact, need to be written to the Response. > > > I'm an idiot. Anyway, it's working now. If others hit the same > > > jquery ->jsonp-> wcf issue let me know. > > > > On Oct 10, 12:07 pm, tenaciousd <[EMAIL PROTECTED]> wrote: > > > > > I'm using jQuery $.ajax to make a cross-domainjsonpcall to a WCF > > > > service. The call is working fine, entering the service endpoint, but > > > > the callback method never fires. I've tried many permutations of > > > > changes and can't seem to get this to work. > > > > > The WCF endpoint is returning a string (NOT doing a Response.Write) > > > > that contains a json object inside the callback wrapper (e.g. > > > > "jsonp123( {"Author":"John Doe","Price":"$35.90"} )" ) and the content- > > > > type returned from the service is application/json; charset=utf-8. > > > > > $.ajax call is below. Any help is much appreciated. > > > > > var data = {"ISBN" : $("#isbn1").val()}; > > > > > $.ajax({ > > > > type: "GET", > > > > cache: false, > > > > url: "http://localhost:63132/Widget.svc/GetProductInfo", > > > > scriptCharset: "utf-8", > > > > dataType: "jsonp", > > > > data: data, > > > > success: function(data, textStatus){ > > > > alert("success"); > > > > }, > > > > error: function(XMLHttpRequest, textStatus, > > > > errorThrown){ > > > > alert('error'); > > > > } > > > > });