如何在html文件中显示php文件的结果 [英] How to display result of php file in an html file

查看:103
本文介绍了如何在html文件中显示php文件的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I need help please. I create html file with 2 tabs. The first tab contains form that takes user input and submit it to php file. I want the result of the php file to be displayed in the second tab. 

HTML file
<ul class="nav">
    <li id="TAB0" class="selected"><a href="#TAB0">Run function</a></li>
    <li id="TAB1"><a href="#TAB1">Results</a></li>
    <li id="TAB2"><a href="TAB2">Help</a></li>
</ul>
<div class="content" id="CONTENT">
    <!--TAB0-->
           <div id = "TAB0" class="active">
            <div class="MainContent">
              <form id='myform' enctype='multipart/form-data' name='myForm'  method='post' action="calculateResults.php">
                      SOME INPUTS HERE
                   <p><input type='button' name="mybut" value='Run'></p>
              </form></div></div>
     <!--TAB1-->
           DISPLAY THE RESULT HERE
     <!--TAB2-->

What is done actually with the above code is display the result in a new window. The php file is already print the output result in some texts and table. I want when I click the button in the first tab to execute .php file and display the result in the second tab not in a new window.

Any help please? 
Thanks, 





我尝试过:



我尝试上面的代码但它在新窗口中显示结果。



What I have tried:

I try the above code but it display the result in a new window.

推荐答案

而不是直接从按钮点击事件调用PHP脚本,使用调用javascript jQuery的AJAX 方法 PUT 获取查询结果并通过设置 innerHTML 属性将其写入 DIV

你会在网上找到很多样本 - 只需谷歌'AJAX GET'。
Instead of calling the PHP script directly from button click event, call a javascript using jQuery's AJAX methods PUT or GET to query the results and write it to a DIV by setting it's innerHTML property.
You'll find a lot of samples on the web - just google for 'AJAX GET'.


这篇关于如何在html文件中显示php文件的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆