D
D
Dilik Pulatov2017-07-22 15:21:50
JavaScript
Dilik Pulatov, 2017-07-22 15:21:50

How to make an ajax request in Vuejs2?

Hello!
Help, in Vu how to make an Ajax request?
and I did this,
wrote such a method and it is called when clicked

getContent(){
  this.$http.get('http://user.loc/users')
  .then(res => {
    console.log(res.data);
  });
}

user.loc/users - here it will return data in json format and works in Yii2 REST API
but on the account such an error just
11c51a0d309043008d7f05f63adfe8b3.jpg
85a0058244ff489290246c36837ebb5a.jpg

tried jQuery.ajax but the same error...and tried to just get data in json format from a simple php file but it doesn't work
where is the mistake? I'm still new to Vu .. if it's not difficult to explain why and where I wrote something ... or show an example

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
EverOne, 2017-07-22
@dilikpulatov

The server must add a special header: Access-Control-Allow-Origin: *
Instead of an asterisk, the server can specify a specific domain that is allowed to receive the response.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question