www.webdeveloper.com
Results 1 to 2 of 2

Thread: [RESOLVED] Ajax & Firefox problem

Hybrid View

  1. #1
    Join Date
    Oct 2008
    Posts
    8

    resolved [RESOLVED] Ajax & Firefox problem

    So I want a form that is submitted with ajax. What I have so far works fine in IE but not in Firefox. Heres my code:

    Code:
    //Sends Sign-Up Form
    function sendsuf(){
    	var ajaxRequest;
    	
    	try{
    		// Opera 8.0+, Firefox, Safari
    		ajaxRequest = new XMLHttpRequest();
    	} catch (e){
    		// Internet Explorer Browsers
    		try{
    			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    		} catch (e) {
    			try{
    				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    			} catch (e){
    				// Something went wrong
    				alert("Your browser broke!");
    				return false;
    			}
    		}
    	}
    	// function that will receive data sent from the server
    	ajaxRequest.onreadystatechange = function(){
    		if(ajaxRequest.readyState == 4){
    				alert(ajaxRequest.responseText);
    		}
    	}
    
    
    //  I think the problem is somewhere below this line
    
    	ajaxRequest.open('POST', 'adduser.php', true);
    	ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    	ajaxRequest.setRequestHeader("Content-length", params.length);
    	ajaxRequest.setRequestHeader("Connection", "close");
    
        	var fullname = document.getElementById('fullname').value;
        	var email = document.getElementById('email').value;
    
    
    	ajaxRequest.send('fullname=' + fullname + '&email=' + email);
    }
    Any ideas?

    Thanks

  2. #2
    Join Date
    Oct 2008
    Posts
    8
    OK so the point is... Don't give you form elements the "name=" parameter instead of "id=" when you're trying to retrieve their id. I'm not sure why that stopped anything from going through, but it did.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles