Passing PHP variable to Jquery without refresh

前端 未结 2 1286
执笔经年
执笔经年 2021-01-27 21:44

I apologize upfront for my lack of jquery knowledge. In this website I am building, a user is presented with a number of thumbnail images representing plants. When a thumbnail i

2条回答
  •  温柔的废话
    2021-01-27 22:14

    Use the jQuery AJAX method to gather data from a PHP file and display it on the page. It is very easy and you can pass any variables (parameters) you like to the page.

    http://api.jquery.com/jQuery.ajax/

    For example:

    // This will send a request to a PHP page
    $.ajax({
        url: "http://example.com/test.php",
        dataType: "html",
        success: function(data){
            // Place the returned data into your content
            $('#image').html(data);
        }
    });
    

提交回复
热议问题