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 8214423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:27:30+00:00 2026-06-07T11:27:30+00:00

I have written a quite simple javascript method, which should send an ajax request

  • 0

I have written a quite simple javascript method, which should send an ajax request to a server, and should finally execute a callback function. The problem is that the given callback isn’t executed. I also see in the chrome developer tools that the request is executed, and returns the wished JSON. I have also set the Content type to application/json.

Here is the code I have used:

this.checkAvailability = function(){
    console.log('Before test');
    $.post('/Roomanizer-Website/Reservation', {
        action: 'checkavailability',
        categoryname: $('#categoryname').val(),
        roomcount: $('#roomcount').val(),
        start: $('#start').val(),
        end: $('#end').val()
    }, function(data){
        console.log('callback');
        console.log(data);
        if(data.available == 'true'){
            $('#start_confirmation').html(data.arrival);
            $('#end_confirmation').html(data.leaving);
            $('#price_confirmation').html(data.price);
            this.nextStep();
        } else {
            alert('There are no free rooms during your chosen period.');
        }
    }, 'json');
};

The ‘Before Test’ is written on the console, but not ‘callback’. But as I have already said, the request is executed, and returns the correct JSON:

{arrival : '20/06/2012', leaving : '28/06/2012', price: '0.0', available: 'true'}

And last i will show the http-header:

Request URL:http://localhost:8080/Roomanizer-Website/Reservation
Request Method:POST
Status Code:200 OK
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Content-Length:97
Content-Type:application/x-www-form-urlencoded
Cookie:JSESSIONID=AF1302ECA526216D8207F365F6802814
Host:localhost:8080
Origin:http://localhost:8080
Referer:http://localhost:8080/Roomanizer-Website/Controller?action=booking
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.52 Safari/536.5
X-Requested-With:XMLHttpRequest
Form Dataview URL encoded
action:checkavailability
categoryname:Economy
roomcount:1
start:20/06/2012
end:28/06/2012
Response Headersview source
Content-Length:81
Content-Type:application/json;charset=ISO-8859-1
Date:Mon, 11 Jun 2012 12:19:45 GMT
Server:Apache-Coyote/1.1

Does anybody know hot to solve this issue?

PS: I am using JQuery 1.5.2

  • 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-06-07T11:27:33+00:00Added an answer on June 7, 2026 at 11:27 am

    Problem solved, as it seems single quotes are not acceptable for the JSON-Parser, so I changed the returning string to

    {"arrival":"20/06/2012","leaving":"27/06/2012","price":"80.0", "available":"true"}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a written a very simple UDP Server using Netty - it quite
I have my web application written in Spring MVC. It is quite simple app
Heads up: I am quite new to Javascript and have so far only written
I have written quite a few Ruby programs, but if I need to show
it's late, I'm tired, and probably being quite dense.... I have written an application
have written this little class, which generates a UUID every time an object of
I have written a bash script which installs a number of packages, however for
I have written this code in JavaScript and works perfectly fine when I include
I'm quite new to programming larger applications. I have now written a command line
I am learning iOS and I have written a simple iPhone app using iOS

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.