<form method="POST" id="cnw" action="javascript:void(null);" onsubmit="call()">
<div class="form-group">
<label>1</label>
<input type="text" name="1" class="form-control" maxlength="20" placeholder="1">
</div>
<div class="form-group">
<label>2</label>
<input type="text" name="2" class="form-control" placeholder="2">
</div>
<div class="form-group">
<label>3</label>
<textarea class="form-control" name="3" rows="3" maxlength="63" placeholder="3" style="margin: 0px 0px 0px -0.5 px; height: 98px; width: 487,5 px;"></textarea>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
function call() {
var msg = $('#cnw').serialize();
$.ajax({
type: 'POST',
url: 'mcnews',
data: msg,
success: function(data) {
aler('OK')
},
error: function(xhr, str){
alert('error Occurred: ');
}
});
}
func(w http.ResponseWriter, r *http.Request) {
// ...
// OR
w.Header().Set("Content-Type", "text/plain")
// OR
w.Write([]byte("This is an example server.\n"))
// OR
fmt.Fprintf(w, "%s", "some string")
}
Find more questions by tags Go