I am trying to access post params in golang which are sent via jquery ajax. Maybe I am missing something obvious. Here are my code snippets
$('form').submit(function(e) {
e.preventDefault();
var jsn = {
vvv = $("#textinput").val();
};
console.log(jsn);
$.ajax({
type: "POST",
async : true,
//enctype: 'multipart/form-data',
url: "/homepage",
data: jsn,
processData: true,
contentType: "application/json",
cache: false,
}).done(function(response){
$("#resultdiv").html(response);
});
});
here is my golang code:
func MainConversion(w http.ResponseWriter, r *http.Request) {
r.ParseForm()
text := r.FormValue("vvv")
fmt.Fprint(w, string(text))
return
})
I have tried f.formValue(), r.Form.get() . Thanks in advance