[英]How do I get output from php file to display in a div on the wordpress page that called it?
I have a php file that returns some lovely formatted data, but it displays in a new page. 我有一个php文件,该文件返回了一些可爱的格式化数据,但是它显示在新页面中。 How do I get it to display in a div on the wordpress page that called the php file? 我如何在显示php文件的wordpress页面上的div中显示它?
The page has the user enter a number of values in form fields, they press submit, those values are passed to the php which uses them to perform the mysql query and return the filtered data. 该页面让用户在表单字段中输入许多值,然后按Submit,这些值将传递给php,php将使用它们执行mysql查询并返回过滤后的数据。
I want my button to say "display data" and when clicked the mysql query data displays in a div on the same page. 我希望我的按钮说“显示数据”,当单击mysql查询数据时,将在同一页的div中显示。
At the moment the output comes via : echo print $display_output;
现在输出通过: echo print $display_output;
from the php file. 从PHP文件。
Well I think you need to use jquery ajax for this. 好吧,我认为您需要为此使用jquery ajax。
var lnk = "the link to the back end php page";
$.ajax({url:lnk,success:function(result){
$("#result_div").html(result);
}});
The above will print out the result in the div with the id "result_div" 上面将在id为“ result_div”的div中打印出结果
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.