-1

The following code isn't working in Chrome and I want to make sure it works in all browsers:

$.ajax({
    url: 'homepage_marquee/marquee_panels.html',
    context: document.body,
    async: false,
    success: function (data) {
        $('.marquee_panel_data').html(data);
        setUpMarquee();
    }
});

The ajax is supposed to cycle through some splash screens which is in the marquee_panels.html file. It only displays the first panel on Chrome. I don't get any errors. Works fine in IE9 and Safari.

I have tried local file access and hosted via Apache.

What am I doing wrong?

NotMe
  • 87,343
  • 27
  • 171
  • 245
CeylonSoft
  • 11
  • 3
  • 3
    What doesn't work ? Have you tried to debug your code ? – Ricardo Alvaro Lohmann Mar 27 '13 at 00:52
  • What is the error reported by the chrome developer tools console? – scones Mar 27 '13 at 00:54
  • Try using an absolute URL instead of a relative one (i.e change it to http://example.com/homepage_marquee/marquee_panels.html). Also note the domain name (example.com) for the ajax call must be the same as the page you have open. – Abhi Beckert Mar 27 '13 at 00:54
  • I think you might be running into issues with Chrome and local file access, similar to this: http://stackoverflow.com/questions/4819060/allow-google-chrome-to-use-xmlhttprequest-to-load-a-url-from-a-local-file When I try running a local `html` and have a local `.js` referenced which does for example a jQuery `.load()` to another local `.html` I get local file access issues but only in Chrome but not in IE9 or latest FF. – Nope Mar 27 '13 at 00:56
  • I tried adding the complete url (example.com and www.example.com prefix) did not do anything different. I also tried disabling the chrome web security but no luck. – CeylonSoft Mar 27 '13 at 01:24
  • @SamuelLiew: No the OP should NOT create a new question on the exact same subject. He already has a question here and needed to expand on it. This will get reopened when it's valid. Creating a new question now will most certainly result in that one getting closed too, which won't look good. – NotMe Mar 27 '13 at 01:49
  • @CeylonSoft: Can you modify your post to add the code for the `setUpMarquee()` function? – NotMe Mar 27 '13 at 01:53

1 Answers1

0

Try adding a leading slash to the url.

url: '/homepage_marquee/marquee_panels.html',

this is a correct relative path.

scones
  • 3,317
  • 23
  • 34
  • The leading slash did not work. The ajax is suppose to cycle through some splash screens which is in the marquee_panels.html. It only displays the first panel on Chrome. I don't get any errors. It works fine in IE9 and Safari. – CeylonSoft Mar 27 '13 at 01:05