在不刷新的情况下将PHP变量传递给Jquery [英] Passing PHP variable to Jquery without refresh
问题描述
我对缺乏jquery知识表示歉意.在我正在建立的这个网站中,向用户展示了许多代表植物的缩略图.单击缩略图时,将启动一个jQuery弹出窗口.我想做的是将具有工厂ID的php变量传递到jquery弹出窗口以显示prper信息.任何帮助将不胜感激.谢谢.
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 is clicked, a jquery popup is initiated. What I would like to be able to do is pass a php variable that has the ID of the plant over to the jquery popup to display the prper information. Any help would be greatly appreciated. Thank you.
http://www.plantcombos.com/header/main_index. php?display = random_mix
推荐答案
使用jQuery AJAX方法从PHP文件收集数据并将其显示在页面上.这非常简单,您可以将所需的任何变量(参数)传递到页面.
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/
例如:
// 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);
}
});
这篇关于在不刷新的情况下将PHP变量传递给Jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!