简体   繁体   English

如何从php文件获取输出,以显示在调用它的wordpress页面上的div中?

[英]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文件。

If you mean without reloading the page, Ajax is what you need. 如果您的意思是不重新加载页面,则需要Ajax If this is not what you meant, describe "new page". 如果这不是您的意思,请描述“新页面”。

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.

相关问题 如何将PHP返回的输出插入HTML <div> ? (我正在使用WordPress) - How do I insert output from a PHP return into an HTML <div>? (I'm using WordPress) 如何在页面上显示php文件输出,从哪里调用? - How to show php file output on Page where from it is called? 如何使用wordpress在没有.php文件扩展名的情况下获取get_page_template_slug()? - How do I get get_page_template_slug() without the .php file extension with wordpress? 尝试在单独的 JS 文件中调用 PHP 脚本,如何将输出显示到我的 HTML 页面上 - Trying to call a PHP script in separate JS file, how do i display the output onto my HTML page 如何在同一页面上的div中显示php结果 - how do I display php results in div on same page 如何有效地让 WordPress 评论显示在主页上? - How do I effectively get WordPress comments to display on home page? 我写了一个php文件,从我的wordpress网站提取数据。 如何创建一个使用此PHP文件定期更新的静态页面? - I wrote a php file that pulls data from my wordpress website. How do I create a static page that uses this PHP file to get updated periodically? 如何获得 wordpress 页面 url php 代码? - how do I get wordpress page url php code? 如何从PHP文件中获取页面URL - How to get the page url where from php file is called 如何在另一个php页面(包括包含GET请求的php页面)上显示超链接的GET输出 - How can i display GET output of a hyperlink on another php page (that includes the php page that contains GET request)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM