vendredi 5 août 2016

Checkbox doesn't change state in Internet Explorer

I know the easiest alternative is to use Firefox/Chrome. However, I have some users that swear by Internet Explorer and won't use anything else.

I have a table, where one of the fields is a checkbox. When the checkbox is clicked, I send an AJAX post message that updates the database, and then I refresh the page to show the checkbox's new state.

The issue is that the checkbox does not change state in IE if a click is done. The page refreshes, but the checkbox state remains the same. Here is my code:

    $strHTML .= "<td align='center'> <input type='checkbox' ".$received." class='receivedCheckbox' onclick='checkboxClicked(\"Received\", ".$ticketNumber.")'/> </td>\n";

I echo the HTML line show here. As you can see, the onClick event executes my Javascript function checkReceived(), which is this:

        //This function handles the clicking of checkboxes in the list
        //It sends an ajax POST message to a separate php file that handles the database updating
        function checkboxClicked(checkboxType, ticketNumber){
            $.ajax({
                type: "POST",
                url: 'updateCheckbox.php',
                dataType: 'json',
                data: {checkboxType: checkboxType, ticketNumber: ticketNumber},

                success: function(result, status){
                    if (status != "success"){
                        console.log("Status: " + status + ", Result: " + result);
                    }
                }
            });

            if(checkboxType == "Received"){
                location.reload();
            }
        }

If anyone can provide any help, that would be great. If anyone needs more information about my code, please let me know!

Thank you everyone!




Aucun commentaire:

Enregistrer un commentaire