0

I have been looking all the day about my strange problem.

I have a page, which is loading dynamically content via ajax (with jQuery), but I think it's not a jQuery problem.

The dynamic page contains a javascript function, let's call it "myTestFunction()", without any parameters.

After document.ready (jQuery) or at the end of the page, I call this function. Firefox runs this function. IE 8 said: object required. I think IE can not find the function.

I am very confused about this IE message. My hope is somebody will have an idea about this. How can I tell IE where the function is?

Kindest regards, many thanks for answers. !!!! This Code explains the Problem, running not tested but it should descript the Problem, i hope. Sorry for the strange "code formatting, this is my first example of code in this editor".

 //example of code, a code like this is loaded by our Framework with ajax in a div. 
 <?      //myclass generates the HTML-Output, and generates the Function
         //myTestFunction in an JavaScript Tag see below 
         $myClass = new MyClass('127.0.0.1/application/file.php');
         echo $myClass->renderHTMLcode();
 ?>

<script>
  // alert 1 for me for testing.    
  alert('ende');
 $(document).ready(function() {
     // alert 2, for me , ready event of jQuery has fired  
     alert('ready');
     // function with the problem
      myTestFunction(); 
             }
    );
   <script>        
function myTestFunction() { alert('fromTest'); } ///... } } ?>
4
  • 5
    Please post your code so we can see how you are defining and calling the function. Commented Aug 11, 2010 at 16:00
  • 1
    More information required. Can you please post your code for the page. Commented Aug 11, 2010 at 16:00
  • 1
    -1 How about a minimum test case that demonstrates your problem? Commented Aug 11, 2010 at 16:12
  • 1
    IE's error messages are total garbage when it comes to telling you what's really wrong. Your function may very well be called, but something within it is attempting to access an object which doesn't exist in IE. Commented Aug 11, 2010 at 16:56

1 Answer 1

0

you should use, window.myTestFunction()

but this is a very strange error ie is giving you. maybe you should take a look at this

Sign up to request clarification or add additional context in comments.

1 Comment

If myTestFunction() gives an "Object expected" error, then window.myTestFunction() will be no help here. The only situation where it would help is when a local variable overrides the global function - but this would also be true of other browsers like Firefox.

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.