Link to home
Start Free TrialLog in
Avatar of Todd Penland
Todd PenlandFlag for United States of America

asked on

My First jQuery Experiment Works in Chrome but not IE11 and Safari. Any idea why?

I've got my first page using jQuery to work perfectly in Chrome, however it doesn't work in IE11.  I'm attaching the relevant code below.  Any idea what I'm doing wrong?

Also, Do any sites exist where I could plug in my code and test whether it will work in various browsers?  That would sure save a lot of time.

(The page in question is located at www.pbkplus.com)

Main page
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.1.0.min.js"></script> <script type="text/javascript" src="http://www.pbkplus.com//cl/StoreNumber_4761/home/js/pbkpluscom_jquerytest.js"></script> <link rel="stylesheet" type="text/css" href="http://www.pbkplus.com//cl/StoreNumber_4761/home/css/pbkpluscom_jquerytest.css"></link><content></content>

Open in new window


External JavaScript file (located in /js subfolder)
/*
$(function() {
	$('h1').addClass('standout');
});
*/
$.ajax({
	type: "GET",
	url: "http://www.pbkplus.com/home/xml/pbkpluscom_jquerytest.xml",
	dataType: "xml",
	success: function(xml) {
		$(xml).find('story').each(function(){
			$('<h3>').html( $('headline', this).html() ).appendTo('content');
			$('<p>').html( $('content', this).html() ).appendTo('content');
			});
	}
});

Open in new window


CSS File (located in /css subfolder)
.standout {
  color:red;
  text-align:left;
  font-size:20pt;
}

.imgfloatr {
	float: right; 
	margin: 0px 0px 15px 15px;
}

.imgfloatl {
	float: left; 
	margin: 0px 15px 15px 0px;
}

Open in new window


XML File (locate in /xml subfolder)
<?xml version="1.0" encoding="UTF-8"?>
<stories>
  <story>
    <headline>Buy Kindles, eBooks, and Accessories at Paperbacks Plus!</headline>
    <content>
		<div class='imgfloatl'><iframe width="125" height="125" scrolling="no" border="0" marginwidth="0" frameborder="0" style="border: none;" src="http://rcm-na.amazon-adsystem.com/e/cm?t=soulforcbook-20&amp;o=1&amp;p=21&amp;l=ur1&amp;category=kindle&amp;banner=1PYTZGNDY2ZTANQ341R2&amp;f=ifr"></iframe></div>
		Paperbacks Plus has partnered with Amazon.com to offer Kindle tablets, readers, accessories, eBooks, and other related products directly to our customers.  By <a href='http://www.pbkplus.com/?page=shop/disp&amp;pid=page_kindlestore'>purchasing your Kindle products here</a> you not only get access to Amazon's vast product catalog, you also help support your local bookseller and keep low-cost new and used books available in your local community.  If you don't see what you want here, please contact us and we'll add the product as quickly as possible.  If you would like to see our line of Kindle products in person, please <a href='http://www.pbkplus.com/?page=shop/disp&amp;pid=page_contact'>visit our store</a> during regular business hours and we'll be glad to demonstrate them for you.  Thank you for your support.
    </content>
  </story>
 <story>
    <headline>Paperbacks Plus now sells and supports the Kobo eReader</headline>
    <content>
		<div class='imgfloatl'><a href="http://click.linksynergy.com/fs-bin/click?id=hYU0qM*5sdg&amp;offerid=314164.187&amp;subid=0&amp;type=4"><img border="0" alt="Kobo Devices" src="http://ad.linksynergy.com/fs-bin/show?id=hYU0qM*5sdg&amp;bids=314164.187&amp;subid=0&amp;type=4&amp;gridnum=4" /></a></div>	
		To better serve our readers who want to continue supporting local independent booksellers but who want the convenience of an eReader, Paperbacks Plus is now an official Kobo Affiliate. Kobo is the manufacturer of a line of eReaders comparable in functionality to the Kindle and Nook readers but available through independent retailers. Watch this space for exciting information to come about the various Kobo eReader platforms and the millions of eBooks available for them - right here at pbkplus.com. As always, feel free to <a href='http://www.pbkplus.com/?page=shop/disp&amp;pid=page_contact'>contact us</a> if you have any questions about getting started with Kobo.
    </content>
  </story>  
  <story>
    <headline>Prioritize Your Favorite Authors</headline>
    <content>
		As we build our online inventory we are starting with our most popular authors. If you would like us to prioritize your favorites, please <a href='http://www.pbkplus.com/?page=shop/disp&amp;pid=page_contact'>contact us</a> and let us know who they are. We will then inventory everything we have by those authors so that you'll be able to see our complete collection whenever you like.
    </content>
  </story>
</stories>

Open in new window

Avatar of Snarf0001
Snarf0001
Flag of Canada image

For starters, look at this line in the header:

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"">

Open in new window


You've got a double quotation mark at the end, which is throwing off all the rest of the markup.
Chrome is nice enough to fix that for you, other browsers aren't.  Try removing that and check for other similar issues and see if that fixes your problem.
Avatar of Todd Penland

ASKER

Thanks Snarf0001.  That part appears to be hardcoded by the template provider - not something I can change.  (I will notify them and ask them to fix it.)  I'm pretty sure that isn't the cause of the problem though because it was that way before I started using jQuery and the previous version of the page loaded without any problems.
IE11 has its own developer tools which include a debugger - you can simply open this and see what is causing the Javascript error
Developer Tools
http://msdn.microsoft.com/en-us/library/bg182326(v=vs.85).aspx
The Debugger
http://msdn.microsoft.com/en-us/library/dn255007(v=vs.85).aspx
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you Chris, that solved the problem.  I changed my datatype to "html" but kept $('headline', this).text() the way it is (with 'html' instead of 'text') because some of my elements contain html tags.

I appreciate the help.