0

I want load cross domain html into my div using ajax call. I have tried YQL but it is not working.

$.ajax({
        url: htmlURL,
        success: function(data){
            $('#divID').append(data);
        },
        error: function(xhr, status){
            alert('error'+xhr);
        }
     })

It should be only client side code, no server side code.

Jason
  • 15,017
  • 23
  • 85
  • 116
Prasad
  • 1,783
  • 5
  • 22
  • 26
  • What error do you get? – Jørgen R Dec 11 '14 at 12:26
  • There are many other questions like this, don't they answer it – Barmar Dec 11 '14 at 12:26
  • 1
    If the external site you're targeting does not support JSONP or CORS - use a proxy. Or you could try [Ajax Cross Origin](http://www.ajax-cross-origin.com/) plugin. – urbz Dec 11 '14 at 12:28
  • The Ajax Cross Origin plugin isn't FOSS, but is bound to just be prewritten code that uses a proxy. – Quentin Dec 11 '14 at 12:30
  • No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access. – Prasad Dec 11 '14 at 13:23

1 Answers1

0

It is a problematic. I would suggest you to use proxy script. If you're using php on server side, you can send your request with cURL and printback response. It will work because the JS and "proxy" PHP will be in the same host.

Adil Aliyev
  • 1,159
  • 2
  • 9
  • 22