Hi,

I am writing web applications since several years now and I am used to the problem. There is no efficient was to debug JavaScript code. In my opinion the tips here are all valid. But as usual the solution is a mix between all suggestion.

Differentiate the scripts needing input from the PERL program and the other. Pack the script scripts which do not rely on PERL variables in libraries in a separate directory and include them at the start of the form:

print CGI::start_html( ... -script=>[ {-type=>'JAVASCRIPT', -src=>'../js/utils.js'}, ] ), "\n";

or

print '<script type="text/javascript" src="../js/utils .js"></script>',"\n";

If your script relies on PERL output you have to place it in the code. Example:

print qq~ <script type="text/javascript"> function Whatsoever() { myElement = window.document.getElementById.... … return true; } </script> ~;

Notice: if you write a multi language application most of your JavaScript will have to be included in the PERL code.

To debug the scripts I use Firefox and Firebug. It has an integrated console that is very useful remains open! Selenium is definitely what you want to test your forms. Easy to learn and to use.

The JavaScript debugging process is clumsy anyway. The alert() statement is very useful at this point in time.... If you designed your forms properly, meaning you thought about what is happening as the user reloads a form it resumes to:

If you did not thought about the reload issue... I recommend you start thinking.

K

The best medicine against depression is a cold beer!

In reply to Re: What is your Javascript-workflow? by Zzenmonk
in thread What is your Javascript-workflow? by morgon

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.