|There's more than one way to do things|
Perl AJAX jQuery, js fileby monx663 (Acolyte)
|on Jan 11, 2021 at 12:29 UTC||Need Help??|
monx663 has asked for the wisdom of the Perl Monks concerning the following question:
This is not exactly a Perl question but, I'm using Perl as the backend programming language that creates HTML so...
I am incorporating AJAX on a CMS written in Perl which has been stable for years. One of the backoffice pages of this CMS, shows a list of items that expose actions that can be carried out on this item. One of these actions is Activate/Inactivate. This is just an icon wrapped around that would call the right Perl script on the server and switch the items' status. I am trying to do this with AJAX/JSON jQuery inline, rather than enforcing a full page reload with the traditional href link to a CGI script.I have written a script on the server that responds to AJAX called with jQuery and completes the desired action and returns dynamic results that update the corresponding hardcoded (div2log) DIV element of the page that called it. <DIV id="div2log"></DIV>
I have created a js file that contains:
But I am not sure how to reference it, and pass it the params that I would have passed to a script using /cgi/script.pl?paramA=1¶mB=2¶m3=3 and 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.Does my question make sense?