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
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    841
    Thanks
    15
    Thanked 9 Times in 9 Posts

    Question $.get ajax and storing in a variable....

    ATM, I have:
    Code:
    $.get("../ajax/Invoices.php?function=getCreditcustomerid="+clientid, function(busy) {
    	alert(busy);
    }
    );
    Which, in turns alerts nothing. Not very spectacular. The ajax is suppose to return the credit (ie: +6.25 or -105.23) or debt the client has.

    I would like to store this in a variable so I can manipulate it and add it to other sections of the page (as this is a page for creating an invoice). However I am having no luck, after searching through the api and tutorials. This seemed to the be way to do it but alas I say again. Alerts nothing. Any idea what I am doing wrong and how to make it right. Thanks.

    Note: I am using jQuery.
    Last edited by dniwebdesign; 06-03-2009 at 05:36 AM. Reason: I am using jQuery.
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com

  • #2
    Regular Coder
    Join Date
    Feb 2009
    Location
    Wheeling, IL
    Posts
    358
    Thanks
    5
    Thanked 62 Times in 60 Posts
    Seems to work fine on my end. Are you sure you're tossing in the proper get variables for your script to return anything? I'm guessing that you need an ampersand somewhere in there:

    "../ajax/Invoices.php?function=getCredit&customerid="+clientid,

    Then again, I might be wrong, but... you do know that jQuery get can also send the required variables on it's own too, right? You could always try the following:

    Code:
    $.get('../ajax/Invoices.php',
    	{
    		function: 'getCredit',
    		customerid: clientid
    	}, 
    	function(busy) {
    		alert(busy);
    	}
    )
    See how that works for you. Additionally, consider getting FireBug and seeing exactly what the php script throws back your way.
    The way to success is to assume that there are no impossible things. After all, if you think something is impossible, you will not even try to do it.

    How to ask smart questions?

  • #3
    Regular Coder dniwebdesign's Avatar
    Join Date
    Dec 2003
    Location
    Carrot River, Saskatchewan
    Posts
    841
    Thanks
    15
    Thanked 9 Times in 9 Posts
    After all the searching, frustration, face palming, it was just because I missed the ampersand. Guess I should have gone to bed earlier...

    I'll keep the other method in mind as I will be calling other things as well. Thanks for your help.
    Dawson Irvine
    CEO - DNI Web Design
    http://www.dniwebdesign.com


  •  

    Posting Permissions

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