Bill
Bill

Reputation: 5150

Jquery and JSON no result

I've made a test fiddle here: http://jsfiddle.net/BjLdQ/2

Where I can enter the number 1 for each HTML field and then I press the login button and I get the JSON back as:

{"code":"2"}

So in my mind, I should be able to do the same with jQuery so I press the (Login Jquery Ajax) text and nothing happens, in jsfiddle or from my local machine?

Any help would be most appreciated.

Upvotes: -1

Views: 142

Answers (2)

Gerson Beltrán
Gerson Beltrán

Reputation: 402

There is an error in the code.

$("#button").click(function() {
     alert("Sending");

      $.ajax({
            type: "POST",
            dataType: 'JSON',
            data: "{'username':'1','password':'1','key':'1','device_Id':'1'}",
            url: "https://api.searchningbo.com/user/login",
            // This was here: },
            success: function(data) {
                alert(data);          

            }

        });
} // It wasnt closed properly   

Upvotes: 1

Rob W
Rob W

Reputation: 349222

Same Origin Policy... You cannot fetch pages from a different origin (MDN).

See Ways to circumvent the same-origin policy for work-arounds.

Upvotes: 5

Related Questions