Reputation: 537
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
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
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