I’m writing a WordPress plugin that uses AJAX and I had everything setup and working fine for awhile. I came back to the code a few hours later and all of the sudden I was getting a failed response, even though the code hadn’t changed. I got the correct JSON response when I loaded the URL directly in my browser, but when I made the $.post() call Firebug showed the response as completely empty.
It turned out that I had accidentally loaded the site via one of it’s domain aliases when I came back to it instead of using the domain that WordPress is configured with. I’m guessing that triggered the same origin policy and Firefox blocked the response.
Any solution to this issues?
Just make sure you redirect all domain aliases to the canonical domain. That’s a best practice for several reasons.