jQuery a is null

Subject:

I did an ajax call with keypress event on the enter button

$(document).keypress(function(e){if(e.which == 13){

I would store the previous value in a vriable with var, store the new value in a variable with var.  If they didn't match it would call an AJAX entry request to the DB.If this happened, it worked fine.  However if the updated variable was changed, and you try to update it again with the previous value (like you made a mistake and try to undo) it would kill the function and jquery would throw a is null

 

2015-04-10 12:34:44gstlouis

What I have changed to fix this (looks fixed anyways), I did not declare the variable with var in javascript and deleted the variable holding the previous value in my success AJAX response.

gstlouis
vote
2015-04-10 12:35:45