Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 7
Trades: 0
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
 
 
Register now for full access!
Old 03-24-2008, 04:48 PM Re: AJAX trouble...need help!!!
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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
__________________
Only a biker knows why a dog sticks his head out the window.

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

Posts: 7
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.70036 seconds with 12 queries