V
V
vohaha2015-11-03 20:49:27
JavaScript
vohaha, 2015-11-03 20:49:27

How to enable cross domain requests?

Help with cross-domain requests.
There is a URL - eportal.com.ua/admin.php?start=1&count=10&brand=brand1
I make a GET request

$.ajax({
        type: "GET"
        url: @.url
        beforeSend: ->
          $('.content-spinner').show()
        complete: ->
          $('.content__spinner').hide()
        success: (data)=>
          @.needfullInfo = $.map(data, (item)->
            {
            id: item.ID
            name: item.NAME
            price: item.PRICE
            brand: item.BRAND
            desc: item.DESCRIPTION
            img_url: item.IMG
            img2: item.IMG2
            weight: item.WEIGHT
            volume: item.VOLUME
            }
          )
          @.attachTemplate()
          return
        error: =>
          $('.content__spinner').hide()
          errorPage = '../../errorPage.html'
          @.container.load(errorPage)
      })

gives an error message
XMLHttpRequest cannot load http://eportal.com.ua/admin.php?start=1&count=10&brand=brand1.
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://192.168.0.100:3000' is therefore not allowed access.

I made a json file with the server response, put it in the project. Everything works fine with him, no errors.
Can something be done on the client side or is it just "there" that something needs to be changed?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergeyj, 2015-11-03
@vohaha

zinoui.com/blog/cross-domain-ajax-request
https://learn.javascript.ru/xhr-crossdomain
Specify the permission for the domain or all connections on the server in the config.

A
Alexander, 2016-04-14
@lasmaster

There is also a good article on this: www.html5rocks.com/en/tutorials/cors

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question