0

I'm loading AJAX content that contains a javascript function inside the AJAX content. I'm using the jQuery .load function and calling done() on completion.

$('#content').load(a, done);

function done()
{
    if(pagejs() == 'function')
    {
        pagejs();
    }
}

I'm not able to get the function to execute in IE 9 but in FF and Chrome the script is executed fine. In IE, I'm getting a SCRIPT5007: Object expected error on the if(pagejs() == 'function') line.

I added the compatibility meta tag: <meta http-equiv="X-UA-Compatible" content="IE=8" /> still with no success.

Here is a sample of the AJAX content:

<div id="about"><h1>About This Website</h1>

<script type="text/javascript">
function pagejs(){alert('content was loaded from dynamic script');}
</script>

<p>This is test AJAX content</p>

In IE, the pagejs(); is undefined. Can someone please tell me how I can get IE to recognize this script? Thank you.

2 Answers 2

1
pagejs() == 'function'

That executes pagejs and compares it's return value to the string function.

You want typeof pagejs === 'function'

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

Comments

0

Try if(typeof(pagejs) == 'function')

Comments

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.