jQuery "Cannot read property 'defaultView' of undefined" error

Viewed 73250

I am using jQuery to post a form field to a PHP file that simply returns 1/0 depending on whether it worked or not...

Extract of the code:

$.ajax({
    url: "ajax/save_text.php", //Relative?!?
    //PHP Script
    type: "POST",
    //Use post
    data: 'test=' + $(this).val(),
    datatype: 'text',
    //Pass value       
    cache: false,
    //Do not cache the page
    success: function(html) {
        if (html == 1) {
            $(this).hide().siblings('span').html($(this).value).show();
                    alert("awesome!");
        } else alert('It didn\'t work!');
    },
    //Error
    error: function() {
        alert("Another type of error");
    }
});

However everytime it is successful (html == 1) the console throws up the error

Uncaught TypeError: Cannot read property 'defaultView' of undefined"

and the alert never happens...?

Google doesn't seem to have much info on this error and jQuery, who knows the cause?

1 Answers
Related