简体   繁体   中英

how to use ajax in jQuery in javascript

I want to post javascript variable to another php file and I search using Ajax may help.I want to get back the data on another php file by "post" method.But I can't use $.ajax({}) directly inside javascript:

function input() {
    $.ajax({
        url : 'update_service.php',
        type : 'POST',
        data : {
            name: name,

        },
        success : function(response) {
            alert(response);
        }
    });

The error message said "unexpected function ajax()". How to fix it?

JQuery Version

$.post( "update_service.php", function( data ) {
  alert( "Data Loaded: " + data );
});

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