0

I have to create a site that looks like tumblr and instagram and shows all pictures which are stored in one directory. When you scroll to the end of the page I want to load new pictures but I am a Ajax beginner and dont have a clue how to do this. I think my program will work but I need a PHP variable in the Ajax call. How can I do this?

Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46
  • possible duplicate of [Call php function from javascript](http://stackoverflow.com/questions/7165395/call-php-function-from-javascript) – m02ph3u5 Sep 15 '15 at 13:08
  • no i dont need a Variable in Javascript. I have to change the Variable in Ajax everytime I reached the end of the side. – FreakyReaper Sep 15 '15 at 13:11
  • just echo it into the javascript – DrunkWolf Sep 15 '15 at 13:12
  • Show some code. What php variable needs to be used in what ajax call? What have you tried already? – MetalMichael Sep 15 '15 at 13:13
  • Take whatever you need from what you get in your ajax call and update whatever structure you have on your client side. Give an example if you want something more specific. – m02ph3u5 Sep 15 '15 at 13:13

1 Answers1

1

You can simply echo it into the script the same way you would echo it onto an html page

<script>
...
var phpvar = <?= $php_variable ?>;
...
</script>
DrunkWolf
  • 994
  • 1
  • 6
  • 18