how to consume JSON data from restful wcf webservice

Hello! Experts,


       I have a scenario where a restful wcf service running at one domain and i want to consume that restful service from my application (running in different domain) through "jquery ajax call" , i am able to hit the web service method  which returns json format but i am not able to get the response json data from the web service .

        I'm  not even getting alert's fired in  success and failure ,so please find the below code where i have tried jquery ajax call in my aspx page and please help me with some information were i'm going wrong along with some sample code or example.

       <script type="text/javascript">


     $(document).ready(function () {

            
     $.ajax({
                type: "GET",
                url: url,
                data: "{ }",
                contentType: "application/json; charset=utf-8",
                dataType: "jsonp",
                crossDomain: true,
                success: function(data) {

                    alert(data);
                },
                failure: function(data) {
                    alert("error");
                }

            });


        })

     </script>

Open in new window


Thank you!
LeverageconsultingAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
It would be a great help if you can post a link to your sample page.  More then likely the issue is another javascript error is preventing this from firing.   You will have to post a link for us to see.
0
smeghammerCommented:
Cross domain standard AJAX won't work. You will need something server-side on your site that makes the HTTP request to the remote domain. Your ajax block then would call this local domian URL as a proxy.

Alternatively, there is a couple of newer techniques that address this. See

http://en.wikipedia.org/wiki/JSONP

and

http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Services

From novice to tech pro — start learning today.