Jump to content

Why is this json script not working in IE7 & 8, but works in all other browsers?


Recommended Posts

I am almost done with my sites rebuild and am now in the testing phase. While testing in IE7 and 8 i found out that becuase of  a json script I have my jquery scripts will not work properly, even though they do in all other browsers, including IE9.

 

The page is: http://www.carcityofdanbury.com/New/?cat=01&do=View&stock=18481

 

The script is the Info Request form, something in this line: ".append("<p>Thank you " + data.name + ",</p><p class=\"indent\">we recieved your info request " + data.for + " on our<br />'.$vehicle.' and will contact you shortly.</p>")" is causing the jquery tabs to no longer work.

 

I did the php and jquery coding, but hired someone to do the json, so I do not know how to fix this. Any ideas?

Tried both suggestions and neither worked... On stackoverflow.com someone said: "The issue is with data.for and it sounds a bit like you (the person who wrote the code) are trying to access one of the reserved names. Even though data.for should be valid, IE doesn't like names which it thinks are special (class for example). data.class would cause a problem in IE, even though it's valid.

 

Try to rename data.for to something else data._for for example. Make sure you update the 01/Resources/infoRequest.php PHP file to return the new value as well." so I changed data.for to data.test and it did solve the issue in IE8, but IE7 still screws up my jquery.

 

Here is the entire code, anybody see anything wrong?

<script language="javascript" type="text/javascript">
$(document).ready(function() {

// Tabs
	$("#tabs").tabs();

// Google map
	$(\'#embed\').gmap3(
		{action: \'addMarker\', lat:41.40372, lng:-73.45844, map:{center: true, zoom: 17, mapTypeId: google.maps.MapTypeId.ROADMAP}}
	);

// Pic popup
	$("#viewPics").fancybox({
		\'type\': \'iframe\', \'transitionIn\': \'fade\', \'transitionOut\': \'fade\', \'width\': 900, \'height\': 500, \'autoScale\': false, \'scrolling\': \'no\'
	});

// Form Validation
	jQuery.validator.messages.required = "";
	$("#infoForm").validate({

		invalidHandler: function(e, validator) {
			var errors = validator.numberOfInvalids();
			if (errors) {
				var message = errors == 1
					? \'You missed 1 required field.\'
					: \'You missed \' + errors + \' required fields\';
				$("li.Error span").html(message);
				$("li.Error").show();
			} else {
				$("li.Error").hide();
			}
		},

		onkeyup: false,
		submitHandler: function(form) {
			$.ajax({
				url: "01/Resources/infoRequest.php",
				type: "POST",
				cache:false,
				data: $("#infoForm").serialize(),
				dataType: "json",
				success: function(data) {
					$("li.Error").hide();
					$("#contact_form").html(\'<div id="message"></div>\');
					$("#message").html("<h2>Info Request Submitted!</h2>")
					.append("<p>Thank you " + data.name + ",</p><p class=\"indent\">we recieved your info request " + data.test + " on our<br />'.$vehicle.' and will contact you shortly.</p>")
					.hide()
					.fadeIn(2500, function() {
						$("#message").append("<p>Would you like to <a href=\"?cat=02&stock='.$stock.'\">prefill an application</a> now?</p>")
					});
				}
			});
		},

	});

});
</script>

Crap... I solved it. There was an extra comma

					onkeyup: false,
				submitHandler: function(form) {
					$.ajax({
						url: "01/Resources/infoRequest.php",
						type: "POST",
						cache:false,
						data: $("#infoForm").serialize(),
						dataType: "json",
						success: function(data) {
							$("li.Error").hide();
							$("#contact_form").html(\'<div id="message"></div>\');
							$("#message").html("<h2>Info Request Submitted!</h2>")
							.append("<p>Thank you " + data.name + ",</p><p class=\"indent\">we recieved your info request " + data.test + " on our<br />'.$vehicle.' and will contact you shortly.</p>")
							.hide()
							.fadeIn(2500, function() {
								$("#message").append("<p>Would you like to <a href=\"?cat=02&stock='.$stock.'\">prefill an application</a> now?</p>")
							});
						}
					});
				},

 

The very last comma in the code had to be removed.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.