title: Jquery rest api post call
body: <p>i have a requirement to develop the chrome extension, in that i need to post the product information using the REST API Service, below is the URL </p>
  
  <pre><code>https://ABCD.com/api/products/?token=XXXXf&amp;product[name]=Headphones&amp;product[price]=100&amp;product[permalink]=headphones1
  </code></pre>
  
  <p>getting the response when directly place in browser..</p>
  
  <p>but i need to post this via JQuery ajax post call.. i tried some ways but no luck..</p>
  
  <p><strong>My attempt:</strong></p>
  
  <pre><code>var product = [{ "name": "128.3657142857143", "price": "7", "permalink": "headphones1"}];
      $.ajax({
          type: "POST",
          url: "URL",
          // The key needs to match your method's input parameter (case-sensitive).
          data: JSON.stringify({ token: 'XXXX', product: product }),
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          success: function (data) { alert(data); },
          failure: function (errMsg) {
              alert(errMsg);
          }
      });
  </code></pre>
  
  <p><strong>Post call</strong></p>
  
  <p>var product = [{ "name": "128.3657142857143", "price": "7", "permalink": "headphones1"}];</p>
  
  <pre><code>$.post("URL", JSON.stringify({ token: 'XXXX', product: product }),
    function (data) {
        alert('success');
    }
  );
  </code></pre>
  
  <p><strong>ERROR</strong>
  XMLHttpRequest cannot load <strong><em>URL</em></strong>. Origin null is not allowed by Access-Control-Allow-Origin.</p>
  
  <p>kindly help me out in how to form the jquery ajax call</p>