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 2 of 2
  1. #1
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,955
    Thanks
    9
    Thanked 726 Times in 720 Posts

    Ajax script not working on Safari 4 Windows

    Evening all

    I have a simple AJAX script that runs when a user clicks an "Add to basket" button. The script calls a php file which updates a database to mark the item as sold, and then submits the form to process a payment.

    The script works perfectly in FF3.6, IE6/7/8, Opera 9 and Chrome 5. In Safari 4 on XP the script appears to run with no errors and the form is submitted correctly - but the php file is not called.

    If I run the php file manually from Safari it's OK.

    Any ideas?

    Code:
    function sellItem(id)
    {
    loadXMLDoc('/shopfiles/sellitem.php?id=' + id );
    document.additem.submit();
    }
    
    function loadXMLDoc(url)
    {
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
    
    }

  • #2
    Senior Coder
    Join Date
    Feb 2009
    Location
    Ilkley, West Yorkshire, UK
    Posts
    2,955
    Thanks
    9
    Thanked 726 Times in 720 Posts
    By experimentation, if I change the async on xmlhttp.open to false, Safari4 works fine. This isn't really the solution I wanted though, as it's perceptibly although not disastrously slower than running asynchronously.
    Last edited by SB65; 04-02-2010 at 09:04 AM.


  •  

    Posting Permissions

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