mark103 Posted March 25, 2013 Share Posted March 25, 2013 (edited) Hi guysI need your help. I am writing the list of code in my javascript and now I want to read my php code from my javascript using with loadjscssfile("test1.php", "js") function. function loadjsfile(filename) { var fileref=document.createElement('script'); fileref.setAttribute("type","text/javascript") fileref.setAttribute("src", filename); document.body.appendChild(fileref); } document.onkeydown = function(ev) { var key; ev = ev || event; key = ev.keyCode; var image1 = document.getElementById("image1").getElementsByTagName("img")[0]; if(key == 13) { if (img1.indexOf('image1_yellow.jpg') != -1) { if (img5.indexOf('picture1_yellow.jpg') != -1) { loadjscssfile("test1.php", "js"); } } } Does anyone know how i can read my php code from javascript? Edited March 25, 2013 by mark103 Quote Link to comment https://forums.phpfreaks.com/topic/276134-read-php-from-javascript/ Share on other sites More sharing options...
mark103 Posted March 25, 2013 Author Share Posted March 25, 2013 does anyone know????????? Quote Link to comment https://forums.phpfreaks.com/topic/276134-read-php-from-javascript/#findComment-1420998 Share on other sites More sharing options...
akphidelt2007 Posted March 25, 2013 Share Posted March 25, 2013 What does you loadjscssfile() look like and what do you mean "read php"? Quote Link to comment https://forums.phpfreaks.com/topic/276134-read-php-from-javascript/#findComment-1421008 Share on other sites More sharing options...
haku Posted March 26, 2013 Share Posted March 26, 2013 Yes, your question is unclear. PHP isn't read. It's a script that is executed on the server, and outputs data to the browser. How exactly do you want your javascript to interact with the PHP? Quote Link to comment https://forums.phpfreaks.com/topic/276134-read-php-from-javascript/#findComment-1421061 Share on other sites More sharing options...
DaveyK Posted March 26, 2013 Share Posted March 26, 2013 (edited) As haku said, even if you call your PHP script, it wont return any PHP but rather the result of said php. So if your php file returns html, the JS will ONLY see the html. Edited March 26, 2013 by DaveyK Quote Link to comment https://forums.phpfreaks.com/topic/276134-read-php-from-javascript/#findComment-1421089 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.