Skip to content

Latest commit

 

History

History
34 lines (31 loc) · 738 Bytes

File metadata and controls

34 lines (31 loc) · 738 Bytes

POST and GET

var data = {'slat':1.02,
             'slong': 1.29}

 $.ajax({
            type : "POST",
            url : "/api/location",
            data: JSON.stringify(data),
            contentType: 'application/json;charset=UTF-8',
            success: function(result) {
                console.log(result);
            }, 
            error: function(result) {
                console.log(result);
            }
        });

async is useful for global variable.

$.ajax({
	        type : "GET",
	        async: false,
            url : "/api/location",
	        // timeout: 1000, 
	        success: function(result) {
	 			slat = result.slat;
	 			slong = result.slong;

	        }
	    });