calling a php function in javascript

后端 未结 2 1428
悲哀的现实
悲哀的现实 2021-01-07 13:10

I dont know how to use ajax in my problem: I have a function in php (assign) that update a temporary table in database, I want to when user user click on a button (feedback

相关标签:
2条回答
  • 2021-01-07 13:53

    There is only one way to call a php function after the page is loaded:

    1.ajax:

    function callPHP() {
        $.ajax ({
            url: "yourPageName.php",
            data: { action : assign }, //optional
            success: function( result ) {
                //do something after you receive the result
            }
        }
    

    in your PHP, write

    if ($_POST["action"] == "assign")
    {
        assign(your parameters); //You need to put the parameters you want to pass in
                                 //the data field of the ajax call, and use $_POST[]
                                 //to get them 
    }
    
    0 讨论(0)
  • 2021-01-07 14:05

    There are many great guides on the internet. I will however suggest you get too know JQuery. It will help you on your learning curve.

    function ajaxCall(){
    $.ajax({
        type: "GET",
        url: "scripts/on/serverside.php"
       });
    };
    
    0 讨论(0)
提交回复
热议问题