Hey. There is a task. Can not decide.
- Locally rises golang server http: // localhost: 64000 /
- At the / login address the user enters the login and password in the form
- These data should be sent to the server (there is also GO), for example, at site.ru/login_check using ajax
- The server receives data shows me in the console and sends the answer to the local machine, for example, true.
Everything. Those. I have to send a request to the server and get an answer from it without reloading the page.
What am I doing?
1) JS + JQ receive data and send
function test(){ let site = "http://site.ru/login_check"; // Формирую строку для преобразования в JSON user_data = '{ "login" : "'+ $('#login').val() +'", "password" : "'+ $("#password").val() +'"}'; // Преобразую в JSON user_data = JSON.parse(user_data); // Выполняю ajax запрос $.ajax({ url: auth_url, type: 'GET', dataType: 'jsonp', crossDomain: true, success: function(data){ alert(data); }, error: function(){ alert("Ошибка"); } }); } 2) I am writing code on the GO on the server. I do not receive the data yet, but I'm trying to send some answer.
func login_check_Handler(w http.ResponseWriter, r *http.Request) { fmt.Print("Вход!") // Дает мне возможность увидеть, что Ajax соединился с сервером (прошел по адресу) // Дальше просто использую пример mapD := map[string]int{"apple": 5, "lettuce": 7} mapB, _ := json.Marshal(mapD) fmt.Fprintf(w, string(mapB)) } PS. import ( "fmt" "encoding/json" "net/http" ) 3) As a result, an error pops up in the browser
ncaught SyntaxError: Unexpected token : And in the Application tab it is. It turns out that I kind of get something, but what’s wrong I don’t understand. And always get out alert ("Error"). 
Ps. In other ways, cross-domain queries could not be done. Can you advise what can be done and how to get the data sent from localhost to site.ru in golang.