Skip to main content

Bug Tracker

Side navigation

#4765 closed enhancement (invalid)

Opened June 15, 2009 09:39AM UTC

Closed November 11, 2009 07:58PM UTC

Last modified March 15, 2012 03:31PM UTC

Ajax/Load, "expected ';' " Bug with internet explorer 6 / 7

Reported by: D.van Loon Owned by:
Priority: minor Milestone: 1.4
Component: ajax Version: 1.3.2
Keywords: load ie Cc:
Blocked by: Blocking:
Description

I was making an Ajax function to load html from another page within my Sharepoint site.

To achieve this goal I used the following code.

<!--============================================-->

<script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.js"></script>

<div id="mydiv"></div>

<script type="text/javascript">

$('#mydiv').load(('http://mylocalurl/page.html .ms-listviewtable'), {}, function(responseText,textStatus,XMLHttpRequest){loadResult(responseText,textStatus,XMLHttpRequest);});

function loadResult(responseText,textStatus,XMLHttpRequest)

{

alert('I am succesfully called' );

}

</script>

<!--============================================-->

What happens:

  • The target div is correctly filled with the content of the page
  • the alert is called.
  • in IE, a Javascript error appears "expected ';'"

Note #1, the line-number of the javascript error varies between refreshes. It appears on ridiculously high line numbers.

Note #2, Firefox does not show the error, nor does the error console or Firebug show any error

Note #3, the error dissapears when the above script is reduced to an alert.

if it helps:

A blogger had a similar problem with the get command, he indicated that the problem occurs in IE when specifying datatype: 'SCRIPT' when the actual call returns html.

Also:

The error cannot be reproduced when creating two simple html pages, and having 'load' get the other.

The error seems to origin from the fact that sharepoint pages are shockfull of included and inline script.

Perhaps a toggle to the 'load' command to choose between reading the response or running the response (which it does now ) would solve the problem.

Alternatively I tried to achieve my goal with the 'get' command, however when 'get'ting the html page it can not be traversed through css identifiers ( $('div') works, $('div.myclassname') does not.

Attachments (0)
Change History (3)

Changed June 16, 2009 12:50AM UTC by dmethvin comment:1

description: \ I was making an Ajax function to load html from another page within my Sharepoint site. \ To achieve this goal I used the following code. \ \ <!--============================================--> \ \ <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.js"></script> \ \ <div id="mydiv"></div> \ \ <script type="text/javascript"> \ \ $('#mydiv').load(('http://mylocalurl/page.html .ms-listviewtable'), {}, function(responseText,textStatus,XMLHttpRequest){loadResult(responseText,textStatus,XMLHttpRequest);}); \ \ \ function loadResult(responseText,textStatus,XMLHttpRequest) \ { \ alert('I am succesfully called' ); \ } \ \ </script> \ \ <!--============================================--> \ \ What happens: \ - The target div is correctly filled with the content of the page \ - the alert is called. \ - in IE, a Javascript error appears "expected ';'" \ \ Note #1, the line-number of the javascript error varies between refreshes. It appears on ridiculously high line numbers. \ Note #2, Firefox does not show the error, nor does the error console or Firebug show any error \ Note #3, the error dissapears when the above script is reduced to an alert. \ \ \ if it helps: \ A blogger had a similar problem with the get command, he indicated that the problem occurs in IE when specifying datatype: 'SCRIPT' when the actual call returns html. \ \ Also: \ The error cannot be reproduced when creating two simple html pages, and having 'load' get the other. \ The error seems to origin from the fact that sharepoint pages are shockfull of included and inline script. \ Perhaps a toggle to the 'load' command to choose between reading the response or running the response (which it does now ) would solve the problem. \ \ Alternatively I tried to achieve my goal with the 'get' command, however when 'get'ting the html page it can not be traversed through css identifiers ( $('div') works, $('div.myclassname') does not. \ I was making an Ajax function to load html from another page within my Sharepoint site. \ To achieve this goal I used the following code. \ \ <!--============================================--> \ \ <script type="text/javascript" src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.js"></script> \ \ <div id="mydiv"></div> \ \ <script type="text/javascript"> \ \ $('#mydiv').load(('http://mylocalurl/page.html .ms-listviewtable'), {}, function(responseText,textStatus,XMLHttpRequest){loadResult(responseText,textStatus,XMLHttpRequest);}); \ \ \ function loadResult(responseText,textStatus,XMLHttpRequest) \ { \ alert('I am succesfully called' ); \ } \ \ </script> \ \ <!--============================================--> \ \ What happens: \ - The target div is correctly filled with the content of the page \ - the alert is called. \ - in IE, a Javascript error appears "expected ';'" \ \ Note #1, the line-number of the javascript error varies between refreshes. It appears on ridiculously high line numbers. \ Note #2, Firefox does not show the error, nor does the error console or Firebug show any error \ Note #3, the error dissapears when the above script is reduced to an alert. \ \ \ if it helps: \ A blogger had a similar problem with the get command, he indicated that the problem occurs in IE when specifying datatype: 'SCRIPT' when the actual call returns html. \ \ Also: \ The error cannot be reproduced when creating two simple html pages, and having 'load' get the other. \ The error seems to origin from the fact that sharepoint pages are shockfull of included and inline script. \ Perhaps a toggle to the 'load' command to choose between reading the response or running the response (which it does now ) would solve the problem. \ \ Alternatively I tried to achieve my goal with the 'get' command, however when 'get'ting the html page it can not be traversed through css identifiers ( $('div') works, $('div.myclassname') does not. \

Is the page being hosted on http://mylocalurl? If not then this is a cross-domain request.

Changed June 17, 2009 10:18AM UTC by D.van Loon comment:2

The page is not hosted locally, in the actual solution however the html is retrieved through a local proxy ( making it a local-domain request ).

( note that if it where a cross-domain request, firefox would have given me all kinds of trouble. Which it isn't. )

The core of the problems resides in the fact that all IE browsers ( I managed to test IE 6, IE 7 and IE 8 ) seem to try and run the html that is being 'load'ed. Whereas Firefox simply reads the html ( which is the desired behavior in this case, and the reason this is a feature-req. not a bug )

Changed November 11, 2009 07:58PM UTC by john comment:3

resolution: → invalid
status: newclosed

All I can figure is that the content/script that you're loading is malformed in such a way that only IE catching the error. I'd suggest checking the loaded script using a tool like JSLint.