SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Aug 2002
    Posts
    385
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Embedding content via javascript

    Hello, I am trying to embed content via javascript using the following code:

    Code:
    <script type="text/javascript" src="http://example.com/script.php"></script>
    When I place the script.php in other servers it works fine (content can be viewed) except with one server, it doesn't return anything (just blank screen). What could be the possible problem, is it a hotlinking issue or something else? Thanks.

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is the server yours? Did you write the PHP? When you put the address into the browser, what can you see?

    Gav


  3. #3
    SitePoint Addict
    Join Date
    Aug 2002
    Posts
    385
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes the server is mine. yes i wrote it. if i put it in the browser it works fine, I can see the output. sample output is like this only:

    document.write('hello world');

  4. #4
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    the sample output.

    If you create a new document on each server that outputs document.write('hello world'); or something simple. Does it work on all servers? Also have you tried setting the content type to text/javascript within the php.


  5. #5
    SitePoint Addict
    Join Date
    Aug 2002
    Posts
    385
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it does work with other servers. it only doesn't work in one server, I was wondering could it be a hotlinking issue?

  6. #6
    SitePoint Addict
    Join Date
    Aug 2002
    Posts
    385
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    by the way

    Also have you tried setting the content type to text/javascript within the php
    it makes it not work with other servers when I do that.

  7. #7
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    then there is something wrong... as technically the script tag shouldn't work unless the content is type text/javascript. So it could be that one server is actually the one thats working correctly.

    On the offending server, can you type in the url into your browser and download the file? If not, then theres a hot linking issue, otherwise its something else.


  8. #8
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    have you specified that the output from the php file is to be javascript?
    Code:
    header("ContentType: application/x-javascript");
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  9. #9
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think thats what I was trying to get at Mark, but I failed to get the correct content type by the looks of it.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •