-2

Possible Duplicate:
Ways to circumvent the same-origin policy

I have to call a REST web service from another IP using an AJAX call in an HTML page. However, cross-domain requests aren't supported in AJAX calls.

I am using JSON-P, but I do not get a result in my application.

Here is my jQuery code for making the JSON-P request:

var makePUTRequest = function () {
            $.ajax({
                type: "POST",
                url: "http:// 
                contentType: "application/jsonp",
                data: '{"username1":"getStates", "password1":"EXPLORE"}',            
                dataType: "jsonp",
                success: function (response) {

                    if (response == ("success").toLocaleLowerCase()) {

                        alert("Loging Successfully!!..");
                        window.location = "patient_list.html";
                    }
                    else {
                        alert("Please Loging Again!!..");
                    }
                },
                beforeSend: function (xhr) {
                    xhr.setRequestHeader("My-Key", 'MyKey123456789');
                },
                error: function (error) {

                    alert("ERROR:", error);

                },
                complete: function () {
                    alert("complete");
                }
            });

        };  
Community
  • 1
  • 1
Suhas
  • 37
  • 9
  • 3
    Take a deep breath, slow down a little, and tell us what you are actually trying to do. And add some linebreaks while you are at it. – kmoney12 Dec 12 '12 at 07:35
  • i want to call rest web service in html page using ajax request.service call is cross domain i mean my webservice is on other domain and my html page is on different domain. – Suhas Dec 12 '12 at 07:52
  • @Suhas: we understand what you're saying, but you're not providing enough information for us to help you. JSON-P is the correct way to carry out a cross-domain AJAX call. If you're trying that, but it's not working, then you need to show us your code and tell us what happens when you run it. – Paul D. Waite Dec 18 '12 at 13:21

1 Answers1

-2
     var makePUTRequest = function () {
                $.ajax({
                    type: "POST",
                    url: "http:// 
                    contentType: "application/jsonp",
                    data: '{"username1":"getStates", "password1":"EXPLORE"}',            
                    dataType: "jsonp",
                    success: function (response) {

                        if (response == ("success").toLocaleLowerCase()) {

                            alert("Loging Successfully!!..");
                            window.location = "patient_list.html";
                        }
                        else {
                            alert("Please Loging Again!!..");
                        }
                    },
                    beforeSend: function (xhr) {
                        xhr.setRequestHeader("My-Key", 'MyKey123456789');
                    },
                    error: function (error) {

                        alert("ERROR:", error);

                    },
                    complete: function () {
                        alert("complete");
                    }
                });

            };  

        </script>

js file 1.7.1.js download from google
Suhas
  • 37
  • 9