I can successfully send an XMLHttpRequest without parameters using this code:
template file:
xhr.open('POST', '/mytemplate');
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onload = function() {
if (xhr.status == 200) {
alert('success');
}
else {
alert('failed:' + xhr.status);
}
}
xhr.send();
router:
r.HandleFunc("/mytemplate", MyHandler).Methods("POST")
But as soon as I try to add parameters I get a 405 error. I only change 2 lines, not sure what I am doing wrong:
template file:
xhr.open('POST', '/mytemplate?param1='+var1+'¶m2='+var2+'¶m3='+var3);
router:
r.HandleFunc("/mytemplate/{param1}/{param2}/{param2}", MyHandler).Methods("POST")