How to return the response after the successful completion of the functions an ajax script?

Hello, is the form
<form method="POST" id="cnw" action="javascript:void(null);" onsubmit="call()">
 <div class="form-group">
 <input type="text" name="1" class="form-control" maxlength="20" placeholder="1">
 <div class="form-group">
 <input type="text" name="2" class="form-control" placeholder="2">
 <div class="form-group">
 <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>

 <button type="submit" class="btn btn-default">Submit</button>

And ajax script:
function call() {
 var msg = $('#cnw').serialize();
 type: 'POST',
 url: 'mcnews',
 data: msg,
 success: function(data) {
 error: function(xhr, str){
 alert('error Occurred: ');

Then I go to process the form, pass in the database and after successful completion I need to get alert.
Please tell me how to do it?
July 9th 19 at 13:39
1 answer
July 9th 19 at 13:41
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")
As well as in the Alert display? - Maybell commented on July 9th 19 at 13:44
success: function(data) { <-- data is something that is arrived from the server.
- Alyson.McClure commented on July 9th 19 at 13:47

Find more questions by tags Go