Link to home
Start Free TrialLog in
Avatar of evibesmusic
evibesmusicFlag for United States of America

asked on

Object does not support this property or method in IE8

Experts,

The following code uses the .ajax() method to submit form data and works in all other browsers except IE8 because IE8 does not play nice with "new FormData()".

I've tried changing the following line from "var fd = new FormData();" to an empty array "var fd = new Array();" or "var fd = [];" but, I get the "Object does not support this property or method" error.

I've tried many iterations of this script but, I still can't get it to work. Is there a way to retrofit this script so that it can submit the form data for modern browsers and IE8?

Cheers!

<!-- BEGIN SHARE PROJECT -->
$(function(){
	$(".share").click(function() {
		var mytitle = $(this).attr("modal_title");
		var destination = $(this).attr("destination");
		$("#dialog").load(destination,null,function() {
			$("#dialog").dialog({
				title: mytitle,
				modal: true,
				width: $(window).width()-($(window).width()/2),
				height: $(window).height()-200,
				open: function(){
					$('textarea').ckeditor();
				},//END OPEN
				buttons: {
					"Send Email": function() {
						//CREATE FormData() ARRAY
						var fd = new FormData();
						//FORM VALUES FOR EVALUTION
						var a3_id = document.forms["email-form"]["a3_id"].value;
						var x = document.forms["email-form"]["recipient"].value;
						var y = document.forms["email-form"]["recipient2"].value; 
						<?php if($user==''){ ?>
							//gather senders email address
							var z=document.forms["email-form"]["sender"].value;
						<?php } ?>
						var recipient_message = CKEDITOR.instances.recipient_message.document.getBody().getChild(0).getText();
						fd.append('recipient', x);
						fd.append('recipient2', y);
						<?php if($user==''){ ?>
							fd.append('sender', z);
						<?php } ?>
						fd.append('recipient_message', recipient_message);
						fd.append('a3_id', a3_id);

						//gather recipient 1 email address
						var xatpos=x.indexOf("@mysite");
						var xdotpos=x.lastIndexOf(".org");
						//gather recipient 2 email address
						var yatpos=y.indexOf("@mysite");
						var ydotpos=y.lastIndexOf(".org");
						<?php if($user==''){ ?>
							var zatpos=z.indexOf("@mysite");
							var zdotpos=z.lastIndexOf(".org");
						<?php } ?>
						//set error variable
						var error=0;
						<?php if($user==''){ ?>
							//if sender email addresses is blank show error
							if(z=='' || z==null){
								error=1;
								alert("Please enter your email address.");
								return false;
							}//END IF
						<?php } ?>
						//if both email addresses are blank show error
						if((x=='' || x==null) && (y=='' || y==null)){
							error=1;
							alert("Please enter at least one email recipient.");
							return false;
						}//END IF
						//if email address 1 is not blank validate email address
						if(x!=''){
							if(xatpos<1 || xdotpos<xatpos+2 || xdotpos+2>=x.length){
								error=1;
								alert("Invalid email address for recipient 1.");
								return false;
							}//END IF
						}//END IF
						//if email address 2 is not blank validate email address
						if(y!=''){
							if(yatpos<1 || ydotpos<yatpos+2 || ydotpos+2>=y.length){
								error=1;
								alert("Invalid email address for recipient 2.");
								return false;
							}//END IF
						}//END IF
						<?php if($user==''){ ?>
							//if email address 2 is not blank validate email address
							if(z!=''){
								if(zatpos<1 || zdotpos<zatpos+2 || zdotpos+2>=z.length){
									error=1;
									alert("Invalid email address for sender email address.");
									return false;
								}//END IF
							}//END IF						
						<?php } ?>						
						//if no errors exist submit form			
						if(error==0){
							//POST FORM DATA AND SHOW SUCCESS MESSAGE						
							$.ajax({
								url: '../scripts/email.php?action=send',
								type: 'POST',
								data: fd,
								processData: false,
								contentType: false
							})//END .ajax()
							.done(
								//ALERT USER THAT PROJECT HAS BEEN SAVED
								function(){
									$(function() {
										$("#email_sent").dialog({								
											title: "Email Sent",
											modal: true,
											buttons: {
												Ok: function(){
													//CLOSE DIALOG IF USER PRESSES OK
													$(this).dialog('close');
												}//CLOSE OK FUNCTION
											},//CLOSE BUTTONS
											close: function(event, ui) {
												//IF USER PRESSES CLOSE BUTTON STILL REDIRECT
												$(this).dialog('close');
											}//END CLOSE FUNCTION
										});//CLOSE $submit_success
									});//END FUNCTION					
								}//END FUNCTION
							);//END .done()
						}//END IF NO ERRORS
					}//END SEND MAIL FUNCTION
				},//END BUTTONS
				close: function(event, ui) {
					$(this).dialog('close'); // remove the content
				}//END CLOSE
			});//END DIALOG
		});//END DIALOG
	});//END MODAL_LINK	
});
<!-- END SHARE PROJECT -->				

Open in new window

Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Hi,
which version of jQuery have you referenced/included?
If it is a version 1.x it should work, if it is a version 2.x then it will not work in IE8, as a lot of compatibility stuff for IE8 has been removed from the library.
HTH
Rainer
Avatar of evibesmusic

ASKER

@Rainer Jeschor:

I am using jquery 1.11.1 and jquery ui 1.11.0.
ASKER CERTIFIED SOLUTION
Avatar of Rainer Jeschor
Rainer Jeschor
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@All:

I am unable to install IE11 in my current development environment.

@Admins: This question is still not answered. Not abandoned by me.
Hi,
can you perhaps post the completely generated HTML / script (IE -> View source)?
Or do you have a link where we can see / test?
Thanks.
Rainer
Finally able to install IE 11 which resolved this issue.