in reply to Perl AJAX jQuery, js file
I have created a js file that contains: ...
.js files are not HTML files and should not contain tags, only pure JavaScript code. Also, if you want this to have maximum reusability, don't use jQuery's $(document).ready - only put JavaScript functions in the file.
But I am not sure how to reference it
That would be e.g. <script src="mycode.js"></script> (should be done after other dependencies like jQuery).
pass it the params that I would have passed to a script using /cgi/script.pl?paramA=1¶mB=2¶m3=3
See jQuery's $.ajax function; I showed an example here - note that this example is regarding dynamic form submission, so the difference is that you don't have a <form>; the important part is the argument $.ajax({ data: ....
I am not sure how to pass it the HTML ID of the DIV that it must update with the visual result of its action on the server.
That would probably be easiest as a parameter to the JavaScript function that you define in your .js file Update: and this function is what you call from the <script> tags embedded in the HTML pages themselves.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl AJAX jQuery, js file
by monx663 (Sexton) on Jan 11, 2021 at 13:13 UTC |