SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    IE ignoring dynamically added form id but 'sees' form element ids

    On a confirmation page I have in an app I show read only data and have an edit button that dynamically replaces that read only data with a form (loaded with the data) so they may edit it. They then click the save button, the data is sent via ajax to a PHP function that updates the session objects and returns the corrected read only data (and replaces the form with it)

    In IE (testing on version 8) it completely ignores the validation and the serialize that sends the data back to the server, literally wiping out the data in the object.

    What has me going nuts is upon further testing I found that IE does 'see' the form elements (via their ids) but completely ignores the form id (which I use to loop through the elements). Here's the code:

    Code:
    $('#edit_policy_info').live('click', function()	{
    
    	if ($(this).val() == 'edit this information') {
    		
    		$.ajax({
    			url: '/admin/functions/policy_info_edit_form.php',
    			type: 'POST',
    			data: 'save=false',
    			success: function(data, textStatus){
    				alert(data);
    				$('#policy_info_div').html(data);
    				}  
    
    			});
    
    		}
    	else	{
    
    		var errors = false;
    		
    		$('#edit_policy_form .required').each(function()	 {
    			alert('in');
    			if (jQuery.trim($(this).val()).length == 0)	{
    				errors = true;
    				$('#' + $(this).attr('name') + '_err').show();
    				}
    			else	{
    				$('#' + $(this).attr('name') + '_err').hide();
    				}
    			
    			});
    
    		if (!errors)	{
    			alert($('#county').val() + ' ' + $('#insured_state').val() + ' ' + $('#insured_acres').val());
    			$.ajax({
    				url: '/admin/functions/policy_info_edit_form.php',
    				type: 'POST',
    				data: 'save=true&' + $('#edit_policy_form').serialize(),
    				success: function(data, textStatus){
    					alert(data);
    					$('#policy_info_div').html(data);
    					}  
    
    				});
    			
    			}
    
    		}
    	
    	});
    The 1st if statement returns the form, works fine but notice in the else the loop:

    $('#edit_policy_form .required').each(function()

    IE doesn't enter the loop (BTW, tested in FF and Chrome and it works perfectly). In the if(!errors) block the alert: alert($('#county').val() + ' ' + $('#insured_state').val() + ' ' + $('#insured_acres').val()); shows the proper data but the $('#edit_policy_form').serialize() fails to send the form's data back to the server.

    Been beating my head against the desk for hours trying to figure this out! Any help would be deeply appreciated, this is holding up a huge project where I use a ton of this type code and I'm dreading I have to re-write it all.

  2. #2
    SitePoint Wizard gold trophysilver trophybronze trophy dc dalton's Avatar
    Join Date
    Nov 2004
    Location
    Right behind you, watching, always watching.
    Posts
    5,431
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Never mind, I found it ... had forgotten the form shut off tags so IE choked on it when no other browser did


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •