monx663 has asked for the wisdom of the Perl Monks concerning the following question:
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>What I would like to do is include the JSON/jQuery stuff in a .js (Javascript) file on the server and only include references to this file where jQuery/AJAX is needed for any item.
I have created a js file that contains:
<script>
$(document).ready(function(){
$("button").click(function(){
$.ajax({url: "/cgi-bin/ajax.pl", success: function(result){
$("#div2log").html(result);
}});
});
});
</script>
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl AJAX jQuery, js file
by haukex (Archbishop) on Jan 11, 2021 at 12:42 UTC | |
by monx663 (Sexton) on Jan 11, 2021 at 13:13 UTC | |
|
Re: Perl AJAX jQuery, js file
by Corion (Patriarch) on Jan 11, 2021 at 13:32 UTC | |
|
Re: Perl AJAX jQuery, js file
by bliako (Abbot) on Jan 11, 2021 at 21:25 UTC | |
by monx663 (Sexton) on Jan 11, 2021 at 22:22 UTC | |
by bliako (Abbot) on Jan 12, 2021 at 10:27 UTC | |
|
Re: Perl AJAX jQuery, js file
by Anonymous Monk on Jan 11, 2021 at 12:36 UTC | |
by monx663 (Sexton) on Jan 11, 2021 at 12:58 UTC | |
by haukex (Archbishop) on Jan 11, 2021 at 13:00 UTC | |
by monx663 (Sexton) on Jan 11, 2021 at 13:21 UTC | |
by marto (Cardinal) on Jan 11, 2021 at 13:31 UTC | |
|