[AJAX] Not working in FF/Chrome, working in IE
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: [AJAX] Not working in FF/Chrome, working in IE

  1. #1
    Join Date
    Mar 2011
    Posts
    2

    [AJAX] Not working in FF/Chrome, working in IE

    Hi guys!

    I've the following AJAX code:
    Code:
    /* ---------------------------- */
    /* XMLHTTPRequest Enable */
    /* ---------------------------- */
    function createObject() {
    var request_type;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
    request_type = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
    request_type = new XMLHttpRequest();
    }
    return request_type;
    }
    
    var http = createObject();
    
    /* -------------------------- */
    /* INSERT */
    /* -------------------------- */
    /* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */
    var nocache = 0;
    function insert() {
    // Optional: Show a waiting message in the layer with ID login_response
    document.getElementById('insert_response').innerHTML = "Just a second..."
    // Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding.
    var site_url= encodeURI(document.getElementById('site_url').value);
    var site_type = encodeURI(document.getElementById('site_type').value);
    // Set te random number to add to URL request
    nocache = Math.random();
    // Pass the login variables like URL variable
    http.open('get', 'insert.php?site_url='+site_url+'&site_type=' +site_type+'&nocache = '+nocache);
    http.onreadystatechange = insertReply;
    http.send(null);
    }
    function insertReply() {
    if(http.readyState == 4){
    var response = http.responseText;
    // else if login is ok show a message: "Site added+ site URL".
    document.getElementById('insert_response').innerHTML = 'Site added:'+response;
    }
    }
    This code works to insert a MySQL record to a Database using AJAX. It works fine on IE, but it's not working on FF or Chrome. When I test it on FF/Chrome, i just get the text "Just a second..." and it doesn't advance from there.
    I don't really know AJAX, so I don't know where the issue is. I would really appreciate your help.

    Regards,
    Federico.-

  2. #2
    Join Date
    Mar 2011
    Posts
    2

    Re: [AJAX] Not working in FF/Chrome, working in IE

    This thread can be closed.
    I've already solved the issue.

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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center