开发者

Popuplate variable using AJAX

Say 开发者_如何学CI have a page...

<?php 
$variable1 = '';
echo "variable 1 = " . $variable1;

Ajax insert funciton 
?>

When my page loads thre userw ill see "variable 1 =" as the variable is undefined. If my ajax function was an insert into DB which gave variable1 a value, am I correct in thinking that the user will still see "variable 1 =" until he reloads the page?

Im trying to understand AJAX so sorry if this is a bit confusing/amateur question

Thanks in advance a


An Ajax call will only change your page if you write code in the page to update the page after the results of the ajax call. If you don't update the page yourself, you are correct that the page will not change until a refresh.

You can think of an ajax call as a remote procedure call to your server and nothing more than that. It only affects the contents of the page if you change the page yourself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜