Jquery ajax jqXHR.status always 0

I am trying to submit a form using AJAX using jquery:

<form name="myform" action="">
<table id="webcam-table">
    <thead>
        <tr>
            <th>Name</th>
            <th>...</th>
            <th><input type="checkbox" name="checkboxselectall" title="Select All" />&nbsp;&nbsp;
                <button type="submit" class="deletebutton" name="delete_video" title="Delete the selected videos">Delete</button></th>
        </tr>
    </thead>
    <tbody>
        <tr >
            <td>some data</td>
            ...
            <td><input type="checkbox" value="<?php echo $this->result_videos[$i]["video_name"]; ?>" title="Mark this video for deletion"/></td>
        </tr>
    </tbody>
</table>
</form>

If someone selects the checkbox and clicks the submit button, I have this code:

jQuery(".deletebutton").on("click", function() {
    var testchecked = jQuery(':checkbox:checked').length;
    if (testchecked == 0) {
        alert('Please select at least one video');
        e.preventDefault();
    }
    else
    {
        if (confirm("Are you sure you want to delete the selected videos?"))
        {
            var checked = jQuery('input:checkbox:checked').map(function () {
                return this.value;
            }).get();
            var $this = jQuery(this);
            jQuery.ajax({
                type: 'POST',
                url: 'index.php?option=com_recordings&task=deletevideos&format=raw',
                data: {checkedarray:checked},
                success: function(data){
                    alert(data);

                }
            });
        }
    }
});

Oddly enough, this code works fine in IE (as it is for a change), but not in Chrome or FF. If I check the error:

error: function(jqXHR, textStatus, errorThrown) {
        if (jqXHR.status === 0) {
            alert("Not connected. Verify Network.");
        }

It seems he always throws this warning. So why is it always 0? Here is a really strange thing. After you play a lot, if I change the form to a table, it works:

<table id="webcam-table">
    <thead>
        <tr>
            <th>Name</th>
            <th>...</th>
            <th><input type="checkbox" name="checkboxselectall" title="Select All" />&nbsp;&nbsp;
                <button type="submit" class="deletebutton" name="delete_video" title="Delete the selected videos">Delete</button></th>
        </tr>
    </thead>
    <tbody>
<form name="myform" action="">
... //the rest is the same

This will work in FF and Chrome, but now IE will not be able to display the table correctly. So this is not a solution (in any case, this is not a valid w3c code). So ... any ideas? Anything I can try to debug?

+4
source share
1 answer

, . , if. if, .

+4

All Articles