943,078 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 1731
  • PHP RSS
Dec 4th, 2009
0

Tried to get PHP inside a Javascript loop to run over and over

Expand Post »
Hi everyone,

As the title of my topic says, I created a javascript loop that had some PHP code inside of it, hoping that every time the javascript function ran, it would re-call the PHP code inside of it.

Turns out my hopes failed - the PHP code is only ran one time when the page loads, and then the javascript function continues to be called as normal (just no PHP).

Is there a way I can get the PHP code to run every time the javascript function is called?

Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
BlackPhoenix is offline Offline
53 posts
since Aug 2009
Dec 4th, 2009
0
Re: Tried to get PHP inside a Javascript loop to run over and over
No
PHP is serverside, only the output of the php is sent to the browser
javascript is clientside,
the two meet in AJAX
whcih has a bit of a leaning curve...

What were you trying to accomplish
instead of "some php"
Reputation Points: 561
Solved Threads: 365
Posting Maven
almostbob is offline Offline
2,964 posts
since Jan 2009
Dec 4th, 2009
0
Re: Tried to get PHP inside a Javascript loop to run over and over
Click to Expand / Collapse  Quote originally posted by almostbob ...
No
PHP is serverside, only the output of the php is sent to the browser
javascript is clientside,
the two meet in AJAX
whcih has a bit of a leaning curve...

What were you trying to accomplish
instead of "some php"
More specifically, I already have a working PHP->MySQL script that I thought was being run inside of the javascript function. The script just queries the database and returns some data which I place into a 2D array.

My goal is to just get the website to query the database when the function is called and return the data again (which may have changed since the last time the javascript function has been called).

Is this possible to do with AJAX?
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
BlackPhoenix is offline Offline
53 posts
since Aug 2009
Dec 5th, 2009
0
Re: Tried to get PHP inside a Javascript loop to run over and over
This is the ideal thing to do with AJAX,
can't ask me how, I dunno
in the adjacent AJAX DHTML Javascript forum there are ajax gurus for whom this is a no brainer, ask the same Q there
Reputation Points: 561
Solved Threads: 365
Posting Maven
almostbob is offline Offline
2,964 posts
since Jan 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: editor...
Next Thread in PHP Forum Timeline: add textbox





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC