funbinod Posted May 27, 2014 Share Posted May 27, 2014 i am trying to create new element that contains a php returned array in it. $( "#invoice" ).append( '<td id="item"><script>getData("items.php", "item")</script></td>'); the array is returned from 'items.php' and is called with simple ajax technique. its not working, or simply i don't know how can i do that. can anyone please guide me or suggest me some better technique...? Link to comment Share on other sites More sharing options...
justsomeguy Posted May 27, 2014 Share Posted May 27, 2014 Get the data from PHP first, then create the element. Link to comment Share on other sites More sharing options...
funbinod Posted May 27, 2014 Author Share Posted May 27, 2014 ok! i got the array first but how can i put that inside "<td></td>" Link to comment Share on other sites More sharing options...
justsomeguy Posted May 27, 2014 Share Posted May 27, 2014 I don't understand what the problem is. What code are you using? You print the data from the array presumably the same way that your function is doing it now. Link to comment Share on other sites More sharing options...
funbinod Posted May 27, 2014 Author Share Posted May 27, 2014 i was using simple ajax method to getData stored on 'items.php' and insert it on the "<td id='items'> </td>" i've this already in my page. <td id="item"><script>getData("items.php", "item")</script></td> it displays everything fine. i wish to add this same line again. but when i .append this element it doesn't work.. Link to comment Share on other sites More sharing options...
justsomeguy Posted May 28, 2014 Share Posted May 28, 2014 That's because appending an element that contains Javascript does not cause the Javascript to get executed. That's why I said to load the data first via ajax, then put the data on the page. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now