title: Golang + ajax post data
body: <p>I've got a page with a number of fields, not in a form setup because I wanna be able to act on them individually and post with ajax. I am using Go to process the post data. However, it seems to post multiple times because in my Go code I am outputting a post variable to the console to test, and it dumps the output 5 times, which represents the number of variables in the post data. I also had this type of behavior when I just used a jquery alert to show the post data. Am I misunderstanding something about how ajax posts, or is there some other bug going on?</p>
  
  <h2>Go code</h2>
  
  <pre><code>func addProduct(w http.ResponseWriter, r *http.Request, p httprouter.Params) {
  
                frmCategory:=r.PostFormValue("category")
                fmt.Println(frmCategory)
  }
  
  func main() {
  
            router:=httprouter.New()
            router.POST("/addProduct",addProduct)
  
  }
  </code></pre>
  
  <h2>AJAX code</h2>
  
  <pre><code>&lt;link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" type="text/css"&gt;
      &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"&gt;&lt;/script&gt;
  
      &lt;script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js" type="text/javascript"&gt;&lt;/script&gt;
  
      &lt;!-- &lt;script src="http://code.jquery.com/jquery-1.4.1.min.js"&gt;&lt;/script&gt; --&gt;
  
      &lt;link rel="stylesheet" type="text/css" href="//netdna.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"&gt;
      &lt;link href="//netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel='stylesheet' type='text/css'&gt;
  
  var postData="bcode\="+ $('#bCodeID').val()+"&amp;category\="+$("#selected_category").val()+"&amp;price\="+priceModifier+"&amp;description\="+$('#itemDescription').val()+"&amp;colorcode\="+$('#SelectedColorCode').val();
  
  $.ajax({
  
          url: '/addProduct',
          type: 'post',
          dataType: 'text',
          data : postData,
          success : function(data) {
                $('#warningBox').modal({
                    show: false
                });
          }
  });
  </code></pre>
  
  <h2>Console output</h2>
  
  <pre><code>Toys
  
  Toys
  
  Toys
  
  Toys
  
  Toys
  
  Toys
  
  Toys
  </code></pre>