Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5939333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:48:49+00:00 2026-05-22T15:48:49+00:00

Greetings, I’ve been with this about 1 or 2 hours and it seems I

  • 0

Greetings,

I’ve been with this about 1 or 2 hours and it seems I cannot find the error in this function I’ve created to check the availability of something in a Database through jQuery and Ajax.

I’m calling the function with this link for test purpouses since I were unable to catch any errors before.

<a href="#" onclick="availability_check("Despacho", "22/05/2011","12:30", "12:45")">TEST</a>

And the code of the Function is the following:

function availability_check(location, date, from, to){  
    var check = 'location='+ location + '&date='+ date + '&from=' + from + '&to=' + to;

    $.ajax({
        type: "POST",
        url: "check-availability.php",
        data: check,
        cache: false,
        success: function(response){
                    var available = response;
                }
    });

    return available;
}

Declared just under the document_ready function.

Could someone smarter than me tell me what’s wrong? Firebug just says:

3

syntax error
[Stop in this error] availability_check(

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:48:50+00:00Added an answer on May 22, 2026 at 3:48 pm

    You have three problems there. First of all, you have quotes inside the onclick attribute. Browsers will think you want to end the attribute, not start a JavaScript string. Try using ' instead of ".

    The second problem is that you’re declaring available inside a closure. When you’re back in availability_check, available will be out of scope. Move var available to above $.ajax and change what’s currently var available = response; to just available = response;.

    The third problem is it seems you don’t understand asynchronicity. $.ajax will be called, starting the request, but the request won’t finish immediately. It will just continue to return available; before the request has completed. Then, once it has completed, it will set available, but by then it’s too late. To fix this, add async: false as another option to $.ajax.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Greetings, I've read some threads about this topic, but actually I was unable to
Greetings. I've been using vim for years, and I've recently started toying with XCode.
Greetings I've been working on a homework in which I must create a linked
Greetings Stack Overflow community. I'm trying to make a function that can pop all
Greetings! I am trying to find a way in Java to programmatically enable/disable a
Greetings! I am trying to find a way in Java to programmatically enable/disable a
Greetings I may have imagined this but does anyone know if Last.fm previously used
Greetings, I have a view based application project where I have created an NSObject
Greetings , I am a new developer in BlackBerry Application. I have been working
Greetings! This is my first question. I've searched all over the web as well

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.