title: cshtml onclick button event and pass a value
body: <p>I have been searching for a solution to this I have a button function </p>
  
  <p>html</p>
  
  <pre><code>&lt;button class="snipcart-add-item btn c8-bg c5-text" onclick="AddProduct(item.Id)"&gt;
  
      @umbraco.library.GetDictionaryItem("USN Shop Add to Basket Listing")
  &lt;/button&gt;
  </code></pre>
  
  <p>item.id has got a value as it works in an original code that I are trying to bypass</p>
  
  <p>java script is </p>
  
  <pre><code>function AddProduct(ptr) {
      $('select').on('click', function () {
          s.ajac({
              url: '/CartSurface/ProductAddToCart',
              data: "{'productId':ptr}",
          }).done(function () {
              alert('Added');
          });
      });
      console.log("Button Pressed")
  }
  </code></pre>
  
  <p>and I get the following error when the button is pressed in the console.log</p>
  
  <p>Uncaught ReferenceError: item is not defined at HTMLButtonElement.onclick</p>
  
  <p>controller </p>
  
  <pre><code>public static void ProductAddToCart(int productId)
  {
    ......
  }
  </code></pre>
  
  <p>I think I have missed something stupidly simple but I cant see it</p>
  
  <p>Following Owns comments</p>
  
  <p>Thanks Own have changed code to     </p>
  
  <pre><code>function AddProduct(value) {
          $('select').on("click", function () {
              s.ajac({
                  url: '/IBDCartSurface/ProductAddToCart',
                  data: "{'productId': value}",
              }).done(function () {
                  alert('Added');
              });
          });
          console.log(value);
          console.log("Button Pressed");
      }
  
  &lt;button class="snipcart-add-item btn c8-bg c5-text" onclick="AddProduct(value)" value="@item.Id"&gt;
  </code></pre>
  
  <p>I get the value in the console and the "Button Pressed" message but my break point dont get triggered and the alert dosnt get triggered.</p>
  
  <p>Can I ask what is the differance between s.ajac and $.ajax other than the latter cant find the url.</p>
  
  <p>Note I have changed the Controller name in the controller as well</p>