Calling javascript within innerHTML

C

Cruelemort

All,

I have recently been using Ajax for a web application i am using,
currently i have an HTML page that contains a div, when this html page
is loaded a javascript function is called to use Ajax to populate the
div with data from a database (by calling a php page and setting the
innerHTML of the div to the returned html from the php page).

The php page contains code to generate html buttons to go into the
div, but depending on the data that is returned from the database this
button may need to be invisible - to do this i figured it would be
best to run a javascript function during the generation (i.e. from the
php page where the database data can be checked) but for some reason
it will not let me call a javascript function from here.

One solution i have come up with to solve this problem is to get the
php page to return a JSON string rather than an HTML string and then
the data can be checked in the javascript rather than the php, but i
do not know if this is the best way to go...

Many thanks.

Ian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top