Reply
AJAX trouble...need help!!!
Old 03-24-2008, 03:32 PM AJAX trouble...need help!!!
Novice Talker

Posts: 6
Hello there guys! Sorry to bother with such a stupid question, but my AJAX script isn't working. What I'm trying to do is send a request to process a credit card payment to a PHP script that I have. The PHP script works 100%, I've tried it, and it works fantastic! However, when I put up the AJAX it stopped working. What I'm trying to do is display a message to the user saying that the payment is processing and for the user not to refresh the page. It works, but it stops when the message is displayed I don't get a response from the PHP script anymore. I took off the display message, and I got a response from the script, but when I put the message up, it stops working. Can anyone help me get the message to show up until the readyState is complete?

Thanks to anyone in advance, really.

Heres the AJAX code -
Code:
function ccCheck(objectID, firstName, lastName, ccType, ccNumber, expDateMonth, expDateYear, cvv2Number, address1, address2, city, state, zip, amount, PaymentType) {
    if(window.XMLHttpRequest)pageRequest = new XMLHttpRequest();
    else if(window.ActiveXObject) pageRequest = new ActiveXObject("Microsoft.XMLHTTP");
    else return false;
        
    pageRequest.onreadystatechange = function() {
    
        if (pageRequest.readyState == 1) {
        // what to do while waiting
            var objectProcessing = document.getElementById(objectID);
            objectProcessing.innerHTML = '<center><b><img src="images/ajax-loader.gif" /> <br />Your payment is being processed...please wait...</b></center>';

        }
        
        if(pageRequest.readyState == 4) {
            var objectPaymentProcessed = document.getElementById(objectID);
            objectPaymentProcessed = pageRequest.responseText;
        
        }
    
    }
    
pageRequest.open('GET', "includes/handlecctransaction.php?firstName=" +firstName +"&lastName=" +lastName +"&creditCardType=" +ccType +"&creditCardNumber=" +ccNumber +"&expDateMonth=" +expDateMonth +"&expDateYear=" +expDateYear +"&cvv2Number=" +cvv2Number +"&address1=" +address1 +"&address2=" +address2 +"&city=" +city +"&state=" +state +"&zip=" +zip +"&amount=" +amount +"&PaymentType=" +PaymentType, true);        
    pageRequest.send(null);

}
Raphy is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 03-24-2008, 03:48 PM Re: AJAX trouble...need help!!!
tripy's Avatar
Fetchez la vache!

Posts: 1,850
Name: Thierry
Location: In the void
Code:
if(pageRequest.readyState == 4) {
            var objectPaymentProcessed = document.getElementById(objectID);
            objectPaymentProcessed = pageRequest.responseText;
        }
Just a guess, but I see something fishy here..
First, you get a DOM reference to an ID of an element in the page, with getElementById().
Then, you change that reference to the content of the text returned by your CC processing script.

I think you might have wanted to update the content of the DOM element, which would be:
Code:
if(pageRequest.readyState == 4) {
  var objectPaymentProcessed = document.getElementById(objectID);
  objectPaymentProcessed.innerHTML=pageRequest.responseText;
}
just like you did on the "please wait" on readystate==1
__________________
Listen to the ducky: "This is awesome!!!"


Last edited by tripy : 03-24-2008 at 03:49 PM.
tripy is offline
Reply With Quote
View Public Profile
 
Old 03-24-2008, 04:02 PM Re: AJAX trouble...need help!!!
Novice Talker

Posts: 6
Yea I just noticed that, updated it, and its fixed. Thanks for your time. Problem is solved!
Raphy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to AJAX trouble...need help!!!
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12027 seconds with 13 queries