I have a html div (with id example
) where i want to print php variable $test
.
My php looks like this:
<?php
function Test(){
//some action;
return 'Hello World!';
}
$test = Test();
echo $test;
?>
Also i have javascript file :
$.get( "ajax/index.html", function( data ) {
$( "#example" ).html( data );
});
What's the problem ?
My html file :
...
<script>
function Ajax(){
$.get( "../Auth/user_save.php", function( data ) {
$( "#example" ).html( data );});
</script>
<div id = "example"></div>
<input type='submit' onClick='Ajax();'></input>
答案 0 :(得分:0)
您的javascript包含html
个链接,但您尝试拨打php
文件:
$.get( "ajax/index.html", function( data ) {
$( "#example" ).html( data );
});
将其更改为
$.get( "ajax/your_php_file.php", function( data ) {
$( "#example" ).html( data );
});