Home  >  Article  >  Backend Development  >  怎么在HTML中获取PHP中某个变量的值

怎么在HTML中获取PHP中某个变量的值

WBOY
WBOYOriginal
2016-06-23 13:59:081278browse

我现在有2个文件,一个sms.php  一个是index.html,我在php文件中,生成了一个变量$a我现在想在html中获取到$a的值,并且进行JS判断


回复讨论(解决方案)

ajax取值

ajax取值
= =有米有教程之类的- -本人新手菜鸟一枚- -果断不懂

把两个文件合并成一个不行吗,在sms.php 最底下引用include('./index.html');
然后在index.html相应的部分直接就行吧

把两个文件合并成一个不行吗,在sms.php 最底下引用include('./index.html');
然后在index.html相应的部分直接就行吧
我是在index.html中把参数提交到php中然后进行判断,只有生成变量- -然后需要在html接受变量值

<html><head><script type="text/javascript" src="http://code.jquery.com/jquery-1.11.0-rc1.js"></script></head><body><script type="text/javascript">    $(document).ready(function(){        $.ajax({            url:"sms.php",            type: "GET",            dataType: "text",            success: function(data){                alert(data);//$a的值            }        })    })  </script></body></html>

sms.php :
<?php$a = 'aaaa';echo $a;?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn