简体   繁体   中英

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/

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM