[jQuery] Re: jsonp to WCF problem
Hi, Could you make the JsonModule and JsonStream objects available? That would save me a couple of hours making them myself. Your help is realy appreciated. Thanks, Edwin Vermeer
[jQuery] Re: jsonp to WCF problem
Hi, I am trying to implement a HttpModule but can't get it to work. Can you please post the code plus config changes? In the documentation it looks like a HttpModule can not work with WCF. When you look at http://msdn.microsoft.com/en-us/library/aa702682.aspx then you will see the folowing sentence: HttpModule extensibility: The WCF hosting infrastructure intercepts WCF requests when the PostAuthenticateRequest event is raised and does not return processing to the ASP.NET HTTP pipeline. Modules that are coded to intercept requests at later stages of the pipeline do not intercept WCF requests. On 20 nov, 08:06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, Could you make the JsonModule and JsonStream objects available? That would save me a couple of hours making them myself. Your help is realy appreciated. Thanks, Edwin Vermeer
[jQuery] Re: jsonp to WCF problem
Ah, i found it. You have to set the aspNetCompatibility Config file: system.serviceModel serviceHostingEnvironment aspNetCompatibilityEnabled=true / Service class: [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required), System.Runtime.InteropServices.GuidAttribute(09A4A7FA-97AC-4CF8- B264-305EB987AC5F)] public class myService : ImyService On 20 nov, 13:15, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I am trying to implement a HttpModule but can't get it to work. Can you please post the code plus config changes? In the documentation it looks like a HttpModule can not work with WCF. When you look athttp://msdn.microsoft.com/en-us/library/aa702682.aspx then you will see the folowing sentence: HttpModule extensibility: The WCF hosting infrastructure intercepts WCF requests when the PostAuthenticateRequest event is raised and does not return processing to the ASP.NET HTTP pipeline. Modules that are coded to intercept requests at later stages of the pipeline do not intercept WCF requests. On 20 nov, 08:06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, Could you make the JsonModule and JsonStream objects available? That would save me a couple of hours making them myself. Your help is realy appreciated. Thanks, Edwin Vermeer
[jQuery] Re: jsonp to WCF problem
On this topic, I found this on MSDN today, seems like it might be a cleaner solution to the problem, has anyone tried a custom message Encoder? I found their sample and I'm going to implement it today, I'll let you know how it goes. On Nov 20, 7:25 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Ah, i found it. You have to set the aspNetCompatibility Config file: system.serviceModel serviceHostingEnvironment aspNetCompatibilityEnabled=true / Service class: [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required), System.Runtime.InteropServices.GuidAttribute(09A4A7FA-97AC-4CF8- B264-305EB987AC5F)] public class myService : ImyService On 20 nov, 13:15, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I am trying to implement a HttpModule but can't get it to work. Can you please post the code plus config changes? In the documentation it looks like a HttpModule can not work withWCF. When you look athttp://msdn.microsoft.com/en-us/library/aa702682.aspx then you will see the folowing sentence: HttpModule extensibility: TheWCFhosting infrastructure intercepts WCFrequests when the PostAuthenticateRequest event is raised and does not return processing to the ASP.NET HTTP pipeline. Modules that are coded to intercept requests at later stages of the pipeline do not interceptWCFrequests. On 20 nov, 08:06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, Could you make the JsonModule and JsonStream objects available? That would save me a couple of hours making them myself. Your help is realy appreciated. Thanks, Edwin Vermeer
[jQuery] Re: jsonp to WCF problem
err... might have been helpful if I included a link. http://msdn.microsoft.com/en-us/library/cc716898.aspx On Nov 20, 5:30 pm, Steve M [EMAIL PROTECTED] wrote: On this topic, I found this on MSDN today, seems like it might be a cleaner solution to the problem, has anyone tried a custom message Encoder? I found their sample and I'm going to implement it today, I'll let you know how it goes. On Nov 20, 7:25 am, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Ah, i found it. You have to set the aspNetCompatibility Config file: system.serviceModel serviceHostingEnvironment aspNetCompatibilityEnabled=true / Service class: [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required), System.Runtime.InteropServices.GuidAttribute(09A4A7FA-97AC-4CF8- B264-305EB987AC5F)] public class myService : ImyService On 20 nov, 13:15, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, I am trying to implement a HttpModule but can't get it to work. Can you please post the code plus config changes? In the documentation it looks like a HttpModule can not work withWCF. When you look athttp://msdn.microsoft.com/en-us/library/aa702682.aspx then you will see the folowing sentence: HttpModule extensibility: TheWCFhosting infrastructure intercepts WCFrequests when the PostAuthenticateRequest event is raised and does not return processing to the ASP.NET HTTP pipeline. Modules that are coded to intercept requests at later stages of the pipeline do not interceptWCFrequests. On 20 nov, 08:06, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi, Could you make the JsonModule and JsonStream objects available? That would save me a couple of hours making them myself. Your help is realy appreciated. Thanks, Edwin Vermeer
[jQuery] Re: jsonp to WCF problem
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'); } });
[jQuery] Re: jsonp to WCF problem
My service setup isn't exactly the same as yours but I think the same solution will work for you. You'll need to add two classes, one that inherits from Stream (we'll call is JsonStream) and another that inherits from the IHttpModule interface (we'll call this JsonModule). The JsonStream class will need a public property to store the name of the callback (e.g. CallbackFunctionName). JsonModule's Init needs to first look for all RequestType = GET and, for all such requests, do a GetValues on callback to see if the caller expects us to make a callback or simply return data. If a callback param is present we need to create a new instance of JsonStream passing the current context's Response.Filter to the constructor and then set CallbackFunctionName to the appropriate value. Then, in JsonStream in the overridden Write method, if CallbackFunctionName has a value you need to do something like (where _stream is the value passed into JsonStream's constructor): string content = CallbackFunctionName + ( + Encoding.UTF8.GetString(bugger) + );; _stream.Write(Encoding.UTF8.GetBytes(content), 0, content.Length); In this way you've decoupled the callback functionality from your WCF service(s) but it just works for cases that require it. Hopefully this implementation will work in your scenario. On Oct 24, 9:22 am, RWF [EMAIL PROTECTED] wrote: 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'); } });
[jQuery] Re: jsonp to WCF problem
Er, bugger should've been buffer. Quite a typo. On Oct 24, 9:58 am, tenaciousd [EMAIL PROTECTED] wrote: My service setup isn't exactly the same as yours but I think the same solution will work for you. You'll need to add two classes, one that inherits from Stream (we'll call is JsonStream) and another that inherits from the IHttpModule interface (we'll call this JsonModule). The JsonStream class will need a public property to store the name of the callback (e.g. CallbackFunctionName). JsonModule's Init needs to first look for all RequestType = GET and, for all such requests, do a GetValues on callback to see if the caller expects us to make a callback or simply return data. If a callback param is present we need to create a new instance of JsonStream passing the current context's Response.Filter to the constructor and then set CallbackFunctionName to the appropriate value. Then, in JsonStream in the overridden Write method, if CallbackFunctionName has a value you need to do something like (where _stream is the value passed into JsonStream's constructor): string content = CallbackFunctionName + ( + Encoding.UTF8.GetString(bugger) + );; _stream.Write(Encoding.UTF8.GetBytes(content), 0, content.Length); In this way you've decoupled the callback functionality from your WCF service(s) but it just works for cases that require it. Hopefully this implementation will work in your scenario. On Oct 24, 9:22 am, RWF [EMAIL PROTECTED] wrote: 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'); } });
[jQuery] Re: jsonp to WCF problem
thanks tenacious for all the help. It sounds like i would just ditch my IIS hosted WCF service, i was under the impression from this link: http://msdn.microsoft.com/en-us/library/cc716898.aspx that it was some how possible to rig WCF to format the response natively but the solution it referrers to does not exist in the samples download. On Oct 24, 9:00 am, tenaciousd [EMAIL PROTECTED] wrote: Er, bugger should've been buffer. Quite a typo. On Oct 24, 9:58 am, tenaciousd [EMAIL PROTECTED] wrote: My service setup isn't exactly the same as yours but I think the same solution will work for you. You'll need to add two classes, one that inherits from Stream (we'll call is JsonStream) and another that inherits from the IHttpModule interface (we'll call this JsonModule). The JsonStream class will need a public property to store the name of the callback (e.g. CallbackFunctionName). JsonModule's Init needs to first look for all RequestType = GET and, for all such requests, do a GetValues on callback to see if the caller expects us to make a callback or simply return data. If a callback param is present we need to create a new instance of JsonStream passing the current context's Response.Filter to the constructor and then set CallbackFunctionName to the appropriate value. Then, in JsonStream in the overridden Write method, if CallbackFunctionName has a value you need to do something like (where _stream is the value passed into JsonStream's constructor): string content = CallbackFunctionName + ( + Encoding.UTF8.GetString(bugger) + );; _stream.Write(Encoding.UTF8.GetBytes(content), 0, content.Length); In this way you've decoupled the callback functionality from yourWCF service(s) but it just works for cases that require it. Hopefully this implementation will work in your scenario. On Oct 24, 9:22 am, RWF [EMAIL PROTECTED] wrote: Thanks for the info. How exactly are you writing directly to the response usingWCF? My IIS hostedWCFservice is basically just acting like a proxy to a windows hostedWCFservice, 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 isjsonp(check their doc but I'm pretty sure that's the case). As forWCFthe 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 aWCFendpoint 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 usingWCFtoo, have you done projects that require an $.ajax POST request to aWCFservice 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-wcfissue let me know. On Oct 10, 12:07 pm, tenaciousd [EMAIL PROTECTED] wrote: I'm using jQuery $.ajax to make a cross-domainjsonpcall to aWCF 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. TheWCFendpoint 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);
[jQuery] Re: jsonp to WCF problem
No problem. Probably I should've been a bit more explicit in reference to the setup. My WCF service is hosted in IIS 7, and the Stream and Callback classes I mentioned are in the same solution as the WCF endpoint. Also, you have to add a line to your web.config file to reference the IHttpHandler subclass (Callback class) so that WCF will recognize it. Further, even though I added that reference to my web.config IIS 7 STILL didn't recognize it. I had to explicitly add the module reference by way of IIS's Modules area. Now, it could be that this was a cache issue or something, and that IIS would've recognized my web.config entry at some point. I will likely refactor this and try to move the Stream and Callback classes to a separate assembly so that any future WCF services could use them again. I haven't tried this out yet but should work fine. Good luck. On Oct 24, 10:23 am, RWF [EMAIL PROTECTED] wrote: thanks tenacious for all the help. It sounds like i would just ditch my IIS hosted WCF service, i was under the impression from this link:http://msdn.microsoft.com/en-us/library/cc716898.aspx that it was some how possible to rig WCF to format the response natively but the solution it referrers to does not exist in the samples download. On Oct 24, 9:00 am, tenaciousd [EMAIL PROTECTED] wrote: Er, bugger should've been buffer. Quite a typo. On Oct 24, 9:58 am, tenaciousd [EMAIL PROTECTED] wrote: My service setup isn't exactly the same as yours but I think the same solution will work for you. You'll need to add two classes, one that inherits from Stream (we'll call is JsonStream) and another that inherits from the IHttpModule interface (we'll call this JsonModule). The JsonStream class will need a public property to store the name of the callback (e.g. CallbackFunctionName). JsonModule's Init needs to first look for all RequestType = GET and, for all such requests, do a GetValues on callback to see if the caller expects us to make a callback or simply return data. If a callback param is present we need to create a new instance of JsonStream passing the current context's Response.Filter to the constructor and then set CallbackFunctionName to the appropriate value. Then, in JsonStream in the overridden Write method, if CallbackFunctionName has a value you need to do something like (where _stream is the value passed into JsonStream's constructor): string content = CallbackFunctionName + ( + Encoding.UTF8.GetString(bugger) + );; _stream.Write(Encoding.UTF8.GetBytes(content), 0, content.Length); In this way you've decoupled the callback functionality from yourWCF service(s) but it just works for cases that require it. Hopefully this implementation will work in your scenario. On Oct 24, 9:22 am, RWF [EMAIL PROTECTED] wrote: Thanks for the info. How exactly are you writing directly to the response usingWCF? My IIS hostedWCFservice is basically just acting like a proxy to a windows hostedWCFservice, 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 isjsonp(check their doc but I'm pretty sure that's the case). As forWCFthe 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 aWCFendpoint 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 usingWCFtoo, have you done projects that require an $.ajax POST request to aWCFservice 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-wcfissue let me know. On Oct 10, 12:07 pm, tenaciousd [EMAIL PROTECTED] wrote: I'm using jQuery $.ajax to make a cross-domainjsonpcall to aWCF service. The call is working fine,
[jQuery] Re: jsonp to WCF problem
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'); } });
[jQuery] Re: jsonp to WCF problem
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'); } });
[jQuery] Re: jsonp to WCF problem
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-domain jsonp call 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'); } });