Sarah McLachlane
Sarah McLachlane

Reputation: 537

jquery get request error

I am trying to make a get request once the user enters an value and pass that value as parameter however nothing happens. The alert outside theget function works fine. here is my code

 $(document).ready(function(){
$( "input[type='text']" ).change(function() {

$.get("http://example.com/get.php?number=1234", function(data, status){
    alert("Data: " + data + "\nStatus: " + status);
    $("#result").html( data );
});
alert("end of script");

     });
    });

https://jsfiddle.net/4rrous4y/3/

Upvotes: 2

Views: 47

Answers (2)

enriquinho
enriquinho

Reputation: 245

I think you are having a cross origin issue here. Basically if the resource you are trying to load is in a different domain than the origin of the request, it won't let you access to it.

Check the console in Google Chrome, some error should be appearing there.

Upvotes: 2

Daniel Waghorn
Daniel Waghorn

Reputation: 2985

To send a parameter along to get.php you need to append a query string.

In your $.get after the URL add ?parameter=value and change the values accordingly.

Upvotes: 2

Related Questions