I am getting this error when I click my submit button
Microsoft JScript runtime error: Unable to get value of the property ‘submit’: object is null or undefined
Here is my submit button
<input type="submit" id="btnSave" name="saveCommand" value="Save" />
and this is the script
$("#btnSave").live('click', function (event) {
$(this).closest('form')[0].submit();
});
Any comments on why I am getting this error ?How to fix this error
Try like this:
Also
.live()is deprecated. If you are using jQuery 1.7 you should use the.on()method:Also what’s the point of using javascript to subscribe to the
.clickevent of asubmitbutton and submit the containing form? That’s what a submit button is intended to do => submit the form in which this button belongs. Or maybe this submit button is not inside a form? This would explain why you are getting the error => theclosestselector returns nothing and there’s nothing to submit.