SPServices in IE8 on a SharePoint 2007 Site

Aug 23, 2013 at 6:30 PM
I hope you don't tire of this, but I appreciate the work each of you takes to help the SharePoint community at large.

I've run into a bit of a problem on my SharePoint 2007 site and hope the experts that haunt this forum can come to the rescue. I have found and used a script that uses SPServices to display the contents of a list in a CEWP. Here's the code:
<script type="text/javascript" src="https://MySite/Documents/jquery.js"></script>
<script type="text/javascript" src="https://MySite/Documents/jquery.SPServices-2013.01.min.js"></script>

<script language="javascript" type="text/javascript">
    $(document).ready(function() {
        $().SPServices({
            operation: "GetListItems",
            async: false,
            listName: "My Status",
            CAMLViewFields: "<ViewFields><FieldRef Name='Title' /><FieldRef Name='Status1' /><FieldRef Name='Status2' /><FieldRef Name='Status3' /></ViewFields>",
            completefunc: function (xData, Status) {
                $(xData.responseXML).SPFilterNode("z:row").each(function() {
                    var liHtml = "<li><div class='item'>" + $(this).attr("ows_Title") + "<br>" + "<div class='gumballs'><div class='stat'>" + $(this).attr("ows_Status1") + "</div>&nbsp;<div class='stat'>" + $(this).attr("ows_Status2") + "</div>&nbsp;<div class='stat'>" + $(this).attr("ows_Status3") + "</div></div></div></li>";
                    $("#itemsUL").append(liHtml);
                });
            }
        });
    });
</script>

<ul id="itemsUL"/>
The great news is that this works as expected in Chrome and even in IE10 (using IE10 Standards and IE9 Standards). But must of my users are going to be running IE8 and the list data do not appear either in IE8 Standards view or on the actual IE8 browser. Given the listing above, what do I need to do to get the list data to appear in IE8?

In my research it appears IE8 doesn't support addEventListener and the workaround is to use attachEvent instead, but I don't know how to do this. I took the time to look through SPServices' documentation and forums and couldn't find anything on this.
Aug 24, 2013 at 3:03 PM
Are there any errors in the DEV console? (F12 in IE8... then refresh the page). What version of jQuery are you using?

Also,
Your last paragraph confuses me... What does addEventListener have to do with this issue? Are you attempting to use it? because I don't see it in the code you posted above.

Overall, in looking at your code, I would only suggest that you place <ul id="itemsUL"/> before the <script> tag that retrieves the data.


Paul.
Aug 24, 2013 at 5:21 PM
Edited Aug 24, 2013 at 5:22 PM
Paul, thanks for taking the time to respond-- good questions.
  1. I'm using IE10, but am changing to IE8 Standards in the dev panel. Everything displays in the panel's IE9 and IE10 Standards views, but IE8 doesn't show any information in the web part.
  2. The jQuery version is 2.0.3. I just picked it up this week, so it's as up to date as it can be. I don't know if there are any known issues between this version and IE8.
  3. I think I got a little ahead of myself with the attachEvent thing. When I switch to the Script area of the dev panel, it lists several errors:
SCRIPT438: Object doesn't support property or method 'addEventListener' 
jquery.js, line 834 character 4

SCRIPT5009: 'jQuery' is undefined 
jquery.SPServices-2013.01.min.js, line 21 character 1

SCRIPT5007: The value of the property '$' is null or undefined, not a Function object 
itemstatus.aspx, line 913 character 5
I tend to discount the second and third because I know the jQuery file is good-- the stuff renders correctly in both IE9 and 10 Standards views, so it isn't a problem with the source files. That leaves the first, which complains about the addEventListener method. In my brief research it appears IE8 has problems with this specific method and requires attachEvent instead. (http://stackoverflow.com/questions/9769868/addeventlistener-not-working-in-ie8) Am I looking at this correctly? I'm fairly new to all this sort of work, so I'm hoping others in the community have dealt with this in the past and know how to deal with it.

Thanks for your help,

AP
Aug 24, 2013 at 5:41 PM
Thats the problem - jQuery v2.x is not compatible with IE8 (http://jquery.com/browser-support/).

_____
Paul

Sent from mobile device.
Aug 24, 2013 at 5:48 PM
One more thing. When picking a 1.x version, review review the home page here to ensure you don't pick one with know issues with SPServices.


--
Sent from Mobile
Aug 24, 2013 at 6:02 PM
Edited Aug 24, 2013 at 6:03 PM
Of course-- browser support! I switched to 1.10.2 and list items now appear in the IE8 Standards view CEWP as I expected them to. Sorry to waste your time on such a trivial problem, but I've learned a valuable lesson.

Do you recommend a version of jQuery other than 1.10.2? Or is there a tried-and-true workhorse that has been extremely dependable? In my look at both the jQuery and SPServices sites, I didn't see any mention of incompatibilities.

Thanks, Paul!
Aug 24, 2013 at 6:16 PM
Np.
I don't remember now, but 1.10 is ok I think.

_____
Paul

Sent from mobile device.
Coordinator
Aug 30, 2013 at 8:51 PM
I try to test with every version of jQuery as they come out, but it's hard to keep up. I'm not aware of any issues with the 1.10.x versions. Yet.

M.
Aug 31, 2013 at 3:23 PM
I just started using 1.10.2 with a project (SPServices 0.7.2 I think) and works ok this far as well.

_____
Paul

Sent from mobile device.