Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    AJAX behaving badly

    Hi, I hope someone can help!

    I have a function which calls a PHP script to insert/update records in a SQL Server DB. The same script needs to be called several times but it only seems to work the first time it is called otherwise I have to close and reopen the browser which defeats the object of the application...what am I doing wrong?

    The function is :

    function insertRecord(qid, qnum, saleamt,thresh,apis1,apis2, randomnumber)
    {


    // var http = "";
    var http = new createRequestObject();
    http.open( 'get', 'insert.php?qid=' + qid + '&qnum='+ qnum +'&saleamt='+ saleamt +'&thresh='+ thresh +'&apis1='+ apis1 +'&apis2=' + apis2 +'&instype=MASTER', false );
    http.send(null);
    }

    Thanks,
    R

  • #2
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    Where is function createRequestObject() defined?

  • #3
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,294
    Thanks
    10
    Thanked 583 Times in 564 Posts
    try replacing your first real line with this:

    Code:
    var http =  !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest;
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%


  •  

    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
    •