How can I "click" a button that performs a JS function through the Firefox web console?

218 Views Asked by At

My website somehow produced a rather interesting issue. We have individual pages for each auction that goes live, and this one in particular got messed up somehow. Typically we have an edit button that allows us to perform various functions, and one of them kills the auction.

My question: is there a way that I can manually enter that kill command into the console on the web browser?

The initial JS for the functions:

$(document).ready(function() {
    $(".remove_doc").click(function() {
        var doc_id = $(this).attr("title");
        var auction_id = $("#auction_id").val();

The "Kill Auction" command looks like this:

} else if(what == 'mark_dead') {
        var confirmKill = confirm("Are you sure you want to kill this auction?");
        if(confirmKill) {
            $.post("edit_auction.php", {id:auction_id, dead:1}, function(data) {
                if(data == 1) {
                    alert("You are now an auction murderer!");
                    location.reload(true);  
                } else {
                    alert("Failed murder attempt!");
                }
            });
        } else {
            alert("Your bullet missed..."); 
        }

Any thoughts on how I can run this operation in the console would help tremendously!

Thanks!

2

There are 2 best solutions below

0
On

Thank you everyone for your help on this!

I was able to figure it out. I just used bits and pieces from all of the advice. The JS command looks like this in the console

$.post("edit_auction.php", {id:1551, sold:1}, function(data) {
                if(data == 1) {
                    alert("Auction has been SOLD!");
                    location.reload(true);  
                } else {
                    alert("Error marking SOLD!?!");
                }
            });

    
1
On

You can try copying the lines of code that actually send the "kill auction" request to your server and see what happens.

By reading your code, the "kill auction" code is this:

 var auction_id = $("#auction_id").val();        
$.post("edit_auction.php", {id:auction_id, dead:1}, function(data) {
            if(data == 1) {
                alert("You are now an auction murderer!");
                location.reload(true);  
            } else {
                alert("Failed murder attempt!");
            }
        });

Try copying and pasting it on the console on the moment you want to kill the auction.