0

I have been given a URL by a partnering company to load content into a DIV. We put the following onto a page:

<div id="catalog"></div>

And then use .get() to put content into it. A problem arises due to the fact that we're using jQuery 1.3.2 on some of the older sites, and the engineering department is not going to update that any time soon. Both .get() and .load() are giving me errors.

I tried things such as:

 $(document).ready(function () {
         $.ajax("http://appserv.ourpartneringcompany.com/catalog/?acct=12345",function(data){
            $('#catalog').html(data);
         });
});

The error goes away, but the data doesn't load. Could I use jQuery.ajax()?

user1729506
  • 975
  • 4
  • 15
  • 28
  • See http://api.jquery.com/load/ , http://api.jquery.com/jquery.get/ , http://api.jquery.com/jQuery.Ajax/ – Musa Jan 16 '15 at 17:59
  • If you change the "html()" to "text()", does that work? Is anything coming back in the data? – dev4life Jan 16 '15 at 18:02
  • The .load() method was added on jquery version 1.0 so it should be available on your jquery 1.3.2. What errors are showing up with the `.get()` or the `.load()` – Jorge F Jan 16 '15 at 18:05
  • @JorgeF The error is "XMLHttpRequest cannot load. Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers." – user1729506 Jan 16 '15 at 18:14
  • Im not an expert but I think thats because you are trying to get some data from another server. Maybe this answer will help you understand better: http://stackoverflow.com/questions/3595515/xmlhttprequest-error-origin-null-is-not-allowed-by-access-control-allow-origin – Jorge F Jan 16 '15 at 22:19

1 Answers1

1

I don't think jQuery 1.3.2 supports that syntax.

Try modifying to:

$.ajax({
  url: "http://....",
  type: "GET",
  success: function(data){
    $('#catalog').html(data);
  }
});
SteamDev
  • 4,294
  • 5
  • 20
  • 29
  • This worked on a test page, but it did not work on our sites. I received this error in the Chrome console: "XMLHttpRequest cannot load. Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers." – user1729506 Jan 16 '15 at 18:11
  • Thats another issue, server related I believe. See this post for potential fixes http://stackoverflow.com/questions/12409600/error-request-header-field-content-type-is-not-allowed-by-access-control-allow – SteamDev Jan 16 '15 at 18:25