Why does Internet Explorer throw an "Object Expected" error?

1

When opening our client front end in IE, I get the error "Object Expected" and it points to the following when I debug. I've googled, but nothing straightforward yet.

$(document).ready(function() {
$("#login_form").bind("submit", function() { processLogin(); return false; })

if ('<?php echo $_GET['email']?>' != '' && '<?php echo $_GET['password']?>' != '' ) {
    $('#login_form').submit();
}});

Joseph

Posted 2011-05-19T22:51:34.250

Reputation: 617

Maybe something like this will be more suited to Stackoverflow? – Sandeep Bansal – 2011-05-19T23:01:24.260

Answers

3

You've got PHP in your JavaScript there, which is screwing up your JavaScript. Specifically, the opening ' in $_GET['email'] is being interpreted by JavaScript as the end of the string, and then it's trying to parse that bit after it as JavaScript code, which obviously it isn't.

Apparently your server is not processing this file through your PHP interpreter; fix that, though, and it looks like your JavaScript code is good (although I only took a cursory glance through it, so I claim no responsibility if it's still broken!).

Kromey

Posted 2011-05-19T22:51:34.250

Reputation: 4 377

What's obnoxious is that it works in EVERY other browser. I've tried changing out quotes so that it recognizes as php and not js, but still no go. What would be a better way of doing it? document.write? Something along the lines more of an echo? I'm kinda stuck. – Joseph – 2011-05-23T22:05:32.450

@Joseph It shouldn't work in any browser -- that is invalid JavaScript code, because your server is apparently not processing the PHP. – Kromey – 2011-05-23T22:08:57.360

I replaces the random php with document.write to separate it out, but still doing it. I can confirm that it works in FF, Chrome and Safari. Whatever the reasons. Any proposed fix? – Joseph – 2011-05-23T23:01:11.337

@Joseph I'd have to see your updated code. However, as @Sandeep has suggested, this is a programming question and more relevant to Stackoverflow, where you will most likely get better responses than you would here. – Kromey – 2011-05-23T23:11:01.887

@Kromney. Okay. I'll repost over there. Thanks for the help :-) – Joseph – 2011-05-23T23:12:30.863