Ajax transfer type rewritten at URL

I have an ajax call that has a generated url through a paginator script:

"http://192.168.1.23:8000/pricing/0/999/null/?page=9" 

The same link is created on the server:

 "https://xxx.xxx.xxx/pricing/0/999/null/?page=9 

Links are passed to this ajax call, in this case they are set as data :

 $.ajax({ url: (data) ? data : '/pricing/' + this.state.country + '/' + this.state.operation + '/' + this.state.optional, type: 'POST', data: { _token: window.token }, success: function (e) { $('#loader-wrapper').fadeOut(); this.setState({ paginator: true, menuActive: false }); this.handleArticles(e); }.bind(this), error: function (err) { alert(err); console.log(err); } }) 

On localhost, the next page loads without any problems, but on the server I get an error 405 - Method Not Allowed .

I am using a combination of react.js and laravel. My route for this type of links:

 post('pricing/{country}/{operation}/{page}', ' PricingController@getArticles '); 

I only know that the method does not allow errors from the get request to post route, but this is not so, since ajax makes an email call, although there is some β€œget data”, and, more importantly, it works on the local host. Does anyone have an explanation for this and how can I solve it?

EDIT

I solved this by adding a get() route. So here is my new question:

How can the ajax type be changed by simply passing in a url containing receive data?

+1
javascript ajax php laravel
source share
1 answer

Is the URL you want to configure located on another site? If so, it could be CORS, so your URL call should return the following headers.

Access-Control-Allow-Origin: * Access-Control-Allow-Headers: Origin, SecurityPrivateKeyID Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS

0
source share

All Articles