Microsoft JScript runtime error: cannot get defaultView property value: object is null or undefined

I have the following script inside my asp.net mvc: -

function deleteconfirmation() { jAlert('The Answer was deleted succsfully', 'Deletion Confirmation'); $(this).fadeOut('slow', function () { $(this).remove(); }); } 

but when it is executed, it will return the following error: "Microsoft JScript runtime error: cannot get property value" defaultView: object is null or undefined "in if(!(e=a.ownerDocument.defaultView)) inside jquery-1.6 . 2.min.js. Hint: this error only occurs if I use IE, it will not happen if I use chrome or firefox !!!! So what could be causing this? BR

+8
jquery asp.net-mvc-3
source share
2 answers

The error is caused by the fact that your $(this) does not refer to anything, but to the window object . It depends on how your function is called. It is best to pass the element you want to use to the deleteConfirmation() function as follows:

 $("#deleteAnswer").bind("click", function() { deleteConfirmation(this); }); function deleteConfirmation(element) { jAlert('Deleted succsfully', 'Deletion Confirmation', function() { alert("The user clicked ok"); // Hides the element that caused the click event $(element).fadeOut('slow', function () { $(element).remove(); }); }); } 

See the jsfiddle example for an example.

If you are trying to make fadeOut the notification window itself, which runs by default, as you already know.

+1
source share

I think you forgot to add the jQuery library link. Check it out and add in jQuery Reference

Another possibility is to forget to add the jAlert link on the page where you are using.

-one
source share

All Articles