I have one variable in Jquery it which I am assigning the value at a button click. Now after the successful execution of the code, I want to make the variable null.
$("#btnAdd").click(function () {
var myDataVariable= {};
myDataVariable.dataOne="SomeData";
myDataVariable.dataTwo="SomeData";
myDataVariable.dataThree="SomeData";
//Pass the value to Database
$.ajax({
success: function (data) {
//If Successfully Inserted Data I want to make "myDataVariable" Null
}
});
});
2
Answers
You can directly set it to null by applying
myDataVariable = null;
But I think it’s unnecessary because it will automatically reset next click .