Is it possible to update data in my SQL database with Javascript?

前端 未结 2 1822
小鲜肉
小鲜肉 2021-01-28 08:24

I\'m starting to learn some of SQL with javascript and i want to put my variable (\"Val_Points from javascript\") into a table (\"Usuarios\") of a user (ex : Robert). It\'s this

2条回答
  •  面向向阳花
    2021-01-28 09:11

    "Standard" approach

    foo.php is the site which contains a button and includes a script:

    
    ...
    
    

    foo.js adds the on click handler:

    $('#update-btn').click(function() {
        $.ajax({
            'url': 'fooHandler.php',
            'method': 'POST',
            'data': {'sid': ..., 'action': 'update', 'value': ...}
            /* 'success': function(data) { ... } */
            /* 'error': function ... */
        });
    });
    

    fooHandler.php handles requests to the server from the clients:

    
    

提交回复
热议问题