khalilov 0 Report post Posted July 23, 2010 Wow its been a while since my last post, its good to be back.I've worked hard on some javascript animation to work along side my game to add more quality. The basic idea for the javascript to take effect is a user presses on something (example: an item), that click calls an ajax function which loads a certain division. Inside that newly loaded content that is viewed in that division there would be javascript functions that would show these animations. However everything loads except the java functions, even the simple alert and document.write dont show. I googled the problem and i couldn't understand the solution.Here is a small example of the problem:test.php <script>//Browser Support Codefunction fun(){ var ajaxRequest; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // Create a function that will receive data sent from the server ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){ var ajaxDisplay1 = document.getElementById('elem'); ajaxDisplay1.innerHTML = ajaxRequest.responseText; } } ajaxRequest.open("GET", "testing2.php", true); ajaxRequest.send(null); }</script><div id=elem>s</div><input type=submit onClick=java script:fun()> testing2.php<script>document.write('s')</script> when you click the submit button the division is reloaded but nothing is shown, my guess is that the java function document.write did not process, if you u redo it with anything thats not a function it would work perfectly.This is problem makes dozens of javascripting hours a waste if not solved.Please help =) Share this post Link to post Share on other sites
Quatrux 4 Report post Posted July 27, 2010 I think you never heard of jQuery or other Javascript frameworks?I suggest you to learn using jQuery, it's popular, it's easy to use and it can do AJAX very easily, at the beginning it may be hard to understand, but once you start using it, you won't stop using it http://jquery.com/It has an Api, it has a lot of things, lots of plugins.. Just search google for tutorials and what you want.. You won't need to do such scripts as above, jQuery works on all browsers and is very fast. Share this post Link to post Share on other sites