Uncaught TypeError: Cannot call method 'XXX' of undefined?

Your local variable weight defined in the function is shadowing the weight variable in the outer scope. Just call the function-local variable something else, like weight_elem.

Your local variable weight defined in the function is shadowing the weight variable in the outer scope. Just call the function-local variable something else, like weight_elem: function addWeight() { var weight_elem = document. GetElementById('inputWeight'); var comment_elem = document.

GetElementById('inputComment'); weight.webdb. AddWeight(weight_elem. Value, comment_elem.

Value); }.

As the error clearly states, weight. Webdb does not exist. Weight is the local DOM element, not the global variable.

Var weight = document. GetElementById('inputWeight'); var comment = document. GetElementById('inputComment'); weight.webdb.

AddWeight(weight. Value,comment. Value); //^^^^ ^^^^^^ // 1 2 You are expecting (1) to refer to the global variable weight that you defined elsewhere, and (2) to refer to the local variable weight.

I hope you see how this causes a problem. In fact, the local variable is always assumed instead of the global. Solution: use different names.

I don't know what you expect the value of this to be in your "success" handler, but I bet it's not what you think. Save this outside the "$.ajax()" call.

I don't know what you expect the value of this to be in your "success" handler, but I bet it's not what you think. Save this outside the "$.ajax()" call: var clicked = this; $. Ajax( // ... success: function(res) { if (res) $(clicked).

Closest('tr').remove(); else // ... }.

Thanks. Didn't think that through. This worked :) – cabaret Sep 7 at 13:40.

Inside your request, $(this) is not the . Remove element. It's a closure problem.So you can assign $(this) to a variable before and call it after.

Thanks for your answer! – cabaret Sep 7 at 13:41 Oh closures... How do I not get thee. Let me count the ways.

– Tchalvak Oct 21 at 17:24.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions