Jump to content

read php from javascript


mark103

Recommended Posts

Hi guys

I 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 by mark103
Link to comment
Share on other sites

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 by DaveyK
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.