简体   繁体   中英

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. How do I get it to display in a div on the wordpress page that called the php file?

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.

I want my button to say "display data" and when clicked the mysql query data displays in a div on the same page.

At the moment the output comes via : echo print $display_output; from the php file.

If you mean without reloading the page, Ajax is what you need. If this is not what you meant, describe "new page".

Well I think you need to use jquery ajax for this.

 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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM