Why doesn't this work?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard Trahan

    Why doesn't this work?

    Consider this code fragment:

    print $q->header(-type => 'application/x-javascript');
    print <<'EOF'
    some_valid_js_1
    some_valid_js_2
    EOF

    where $q is a CGI object. The above works ok.

    Now change it to this:

    print $q->header(-type => 'application/x-javascript');
    print <<'EOF'
    some_valid_js_1
    EOF
    print <<'EOF'
    some_valid_js_2
    EOF

    In this case, neither line of js code gets to the destination page.
    This behavior is the same for NN 7.1 and IE 6.0.

    What am I doing wrong here?

  • Richard Trahan

    #2
    Re: Why doesn't this work?

    (I'm answering my own post)

    I forgot the g-d semicolon after the print statement.
    A common error when using 'here' documents. Shame on me.

    Comment

    • Evertjan.

      #3
      Re: Why doesn't this work?

      Richard Trahan wrote on 10 aug 2004 in comp.lang.javas cript:[color=blue]
      > Consider this code fragment:
      >
      > print $q->header(-type => 'application/x-javascript');
      > print <<'EOF'
      > some_valid_js_1
      > some_valid_js_2
      > EOF
      >
      > where $q is a CGI object. The above works ok.
      >
      > Now change it to this:
      >
      > print $q->header(-type => 'application/x-javascript');
      > print <<'EOF'
      > some_valid_js_1
      > EOF
      > print <<'EOF'
      > some_valid_js_2
      > EOF
      >
      > In this case, neither line of js code gets to the destination page.
      > This behavior is the same for NN 7.1 and IE 6.0.
      >
      > What am I doing wrong here?[/color]

      Wrong NG ?

      [Seems a different serverside language]

      --
      Evertjan.
      The Netherlands.
      (Please change the x'es to dots in my emailaddress)

      Comment

      • Randy Webb

        #4
        Re: Why doesn't this work?

        Richard Trahan wrote:
        [color=blue]
        > What am I doing wrong here?[/color]

        Not withstanding your own answer (the semicolon), your first problem is
        you are assuming its a client issue when its a server issue.
        The second is that you are asking about PHP code (presumably, it
        resembles PHP) in a Javascript group. Try comp.lang.php or alt.php


        --
        Randy
        comp.lang.javas cript FAQ - http://jibbering.com/faq

        Comment

        Working...