0

I have this code in on my desktop:

$(function () {
    $('#country_link').on('click', function () {
        $.ajax({
            type: 'GET',
            dataType: 'html',
            url: '/ajax.html',
            timeout: 5000,
            beforeSend : function() {
                $("#country_slide").show('fast');
                $("#country_slide").html('<p>Loading</p>')
            }, 
            success: function (data, textStatus) {
                $("#country_slide").html(data);
                alert('request successful');
            },
            error: function (xhr, textStatus, errorThrown) {
                alert('request failed');
                $("#country_slide").hide('fast');
            },
            complete : function() {
               $('.loader').hide();
            }, 
        });
        return false;
    });
});

I also have an ajax.html file with the following content:

<p>Hello World</p>

When I click the link I always get the message "request failed". The message console gives me is this:

Origin null is not allowed by Access-Control-Allow-Origin. test.html:1

I'm a bit confused, since these files are both local why does it complain about the origin?

J.Zil
  • 2,397
  • 7
  • 44
  • 78

0 Answers0