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()?

5
  • See api.jquery.com/load , api.jquery.com/jquery.get , api.jquery.com/jQuery.Ajax Commented Jan 16, 2015 at 17:59
  • If you change the "html()" to "text()", does that work? Is anything coming back in the data? Commented Jan 16, 2015 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() Commented Jan 16, 2015 at 18:05
  • @JorgeF The error is "XMLHttpRequest cannot load. Request header field X-Requested-With is not allowed by Access-Control-Allow-Headers." Commented Jan 16, 2015 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: stackoverflow.com/questions/3595515/… Commented Jan 16, 2015 at 22:19

1 Answer 1

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);
  }
});
Sign up to request clarification or add additional context in comments.

2 Comments

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."
Thats another issue, server related I believe. See this post for potential fixes stackoverflow.com/questions/12409600/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.