简体   繁体   中英

javascript: ajax call not working

I have a javascript file which sends lat and lon to database, calling insertLocation.php

the file path is proj/services/insertlocation (I don't know if I have the right path)

function updateLocation(){
        $.ajax({
            url: '/services/insertLocation.php',
            type: 'POST',
            data: {
                lat: $lat,
                lon: $lon,
                userid: 0
            }
        }).done(function(data){
            alert("data saved");
        });
    }

the insertLocation.php works fine when ran independantly

Any ideas?

Have you try to add a fail in your ajax:

.fail(function( jqXHR, textStatus ) {
  alert( "Request failed: " + textStatus );
});

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