javascript:ajax调用无法正常工作

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 );
});