#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Posts
    233
    Rep Power
    12

    call php(with output) from javascript


    im trying to call the php page from javascript in this way , but dont works

    <SCRIPT LANGUAGE="JavaScript">
    var mycode="<scr" + "ipt language='javascript' src=htt" + "p://www.mysite.com/image_script.php?UserID=entropia"+"></sc"+"ript>";
    document.open();
    document.write(mycode);
    document.close();
    </script>

    the browser dont display the image that should be generated from the PHP script, but just a javascript error

    ps
    this is the code i copied into html page where i want display the image


    i figured out the it works only if the php script dont display something. example if the php script just store data into db it works fine, but for display the image it dont work, how to do ?
  2. #2
  3. Muhhnnn !!
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Apr 2003
    Posts
    1,530
    Rep Power
    89
    if you want to display an imagethen you must enclose your url in an <img> tag, not in a <script> tag.
  4. #3
  5. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2001
    Location
    UK
    Posts
    543
    Rep Power
    58
    the way I do this is to code the whole script into a file, such as:
    PHP Code:
    <?
    //whatever fuctions you like...
    $result //your desired output
    echo "document.write('$result')";
    ?>
    Then on your webpage:
    <script language="JavaScript" src='http://www. mysite/myscript.php' charset="ISO-8859-1"></script>

IMN logo majestic logo threadwatch logo seochat tools logo