Home javascript Uncaught ReferenceError: is not defined

Uncaught ReferenceError: is not defined




I understand, maybe this is a slight mistake. But already a lot of time I can’t solve it.

There is a table with a delete button in each table record, when the button is clicked, an ajax request should be sent, but this generates an error.

Function call button

& lt; td data-label = "Remove" & gt;
      & lt; a href = "#" onclick = "removeItemFromCart ('Click!')" data-line = "0" data-id = "6154534944950" class = "cart__remove icon icon-x text-right large - text-center "& gt; & lt; / a & gt;
     & lt; / td & gt;


& lt;! - AJAX request - & gt;
& lt; script src = "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type = "text / javascript" & gt; & lt; / script & gt;
& lt; script & gt;
  $ (document) .ready (function () {
    function removeItemFromCart (id) {
      alert (id)
& lt; / script & gt;

I receive –
enter image description here

Answer 1, authority 100%

Here is crossover question neighbors. As in this question, I also wonder why ready is needed in this situation? ready is meant to execute some code only after the DOM has loaded. But why do you need to declare functions in it?

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions