mark103 Posted March 25, 2013 Share Posted March 25, 2013 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? 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????????? 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"? 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? 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 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. Link to comment https://forums.phpfreaks.com/topic/276134-read-php-from-javascript/#findComment-1421089 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.