0

When i try to do this:

$.ajax ({
    url: location.hash,
    method: 'GET',
    dataType: 'html',
    success: function (data, textStatus, jqXHR) {
        $('#content').html(data);
    },
    error: function (jqXHR, textStatus, errorThrown) {
        console.log(textStatus);
    }
});

I get this error: Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check http://xhr.spec.whatwg.org/.

My url is: localhost/index.php#test.php

It should use test.php as url to load.

What i need is when there is a hash in the url, i need to load the hash (filename)..

Edit:

When i add:

async: false,

I still get the same error..

Edit:

I am using jQuery version 2.1.3

yooouuri
  • 2,578
  • 10
  • 32
  • 54
  • Duplicate of http://stackoverflow.com/questions/27736186/jquery-has-deprecated-synchronous-xmlhttprequest ? – Xander Luciano Apr 28 '15 at 07:01
  • is there any reason as to why you aren't using simple url url: 'localhost/test.php', – shadab Apr 28 '15 at 07:04
  • It's not listed in your code example, but to see that warning you must be using `async: false`. If so, remove it. It's bad practice anyway. – Rory McCrossan Apr 28 '15 at 07:04
  • Sorry guys i forgot to add, but when i try with async: false i still got the same error... – yooouuri Apr 28 '15 at 07:05
  • A side note: the `url` should be `url: location.hash.replace('#', '')`, because `location.hash` returns the hash with the hash symbol **#** – Ivan Dokov Apr 28 '15 at 08:33

0 Answers0