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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:36:11+00:00 2026-06-17T18:36:11+00:00

I am using the ajax call from json. I call the hotel list from

  • 0

I am using the ajax call from json. I call the hotel list from the ajax call but now I have to call the price for particular hotel. Kindly support.

Code for Hotel List is as follows:
HTML

<td style="color: #993300"><strong>Add Services<input name="add-service" id="add-service" type="button" value="+" style="background-color: #993300; color: #FFFFFF;" /></strong></td>

JQuery For calling ajax to get hotel list:

$('#cmb_service').bind('change', function(){

        var value = $(this).val();
        var destination = $( "#destination" )
        $.ajax({
                type : 'POST',
                url : '../enquiries/getpricebyajax',
                dataType : 'json',
                data: {
                        service : value,
                        destno : destination.val()
                },
                success : function(data) {
                       $('#waiting').hide(500);
                       $('#divserviceprovider').text('');
                       $('#divserviceprovider').append(data.msg);
                       $('#divserviceprovider').show(500);
                       if (data.error === true)
                            $('#divserviceprovider').show(500);
                },
                error : function(XMLHttpRequest, textStatus, errorThrown) {
                        $('#waiting').hide(500);
                        $('#divserviceprovider').removeClass().addClass('error')
                            .text('There was an error.').show(500);
                        $('#divserviceprovider').show(500);
                }
        });
        return false;
});`

PHP code to response of hotel list is as follows:

function getpricebyajax()

{
            $str="";$substr="";
            if(!empty($_POST['service']))
                {
                    switch ($_POST['service']) {
                        case "3":
                            {
                                $rshotels=$this->Enquiry->query("SELECT id, name FROM hotels where destination_id=".$_POST['destno']);
                                foreach($rshotels as $hotel){
                                        $substr.='<option value="'.$hotel['hotels']['id'].'">'.$hotel['hotels']['name'].'</option>';
                                }
                                $str.= '<select id="cmb_hotel" name="cmb_hotel">'.$substr.'</select>';
                                $str.= '<div id="divhotel_details"></div>';
                            }
                            break;
                        default:
                            break;
                    }
                    $return['error'] = true;
                    $return['msg'] = $str;
                }
            exit(json_encode($return));
    }

`

I direct paste the code of html in div. It is well showing the hotel list. But what will be the code for the select “divhotel_details”. When I click on divhotel_details I have to call ajax again to generate the price for that hotel.

Please suggest me.

Thanks in advance.

  • 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-17T18:36:13+00:00Added an answer on June 17, 2026 at 6:36 pm

    you can check it here the correct way to call a json service 🙂 – https://rvieiraweb.wordpress.com/2013/01/21/consuming-webservice-net-json-using-jquery/

    Edit:

    <script>
    
    function AjaxCall(){
      var hotel_val = $("#ddl_hotel").val();
    
       //do service ajax call passing the hotel val 
    
       success: function(response) {
         $("#display_info").empty();
         //this 
         $("#display_info").append(response.Yourfields);
         //or LOOP and show in div
       }, 
       error: function(response) {
           $("#display_info").append("No info for this hotel");
       }
    }
    </script>
    
    <select id="ddl_hotel" onchange="AjaxCall();">
      <option value="hotel1">Hotel 1</option>
      <option value="hotel2">Hotel 2</option>
      <option value="hotel3">Hotel 3</option>
    </select>
    
    <div id="display_info">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using $.ajax call for download excel from .aspx page. But ajax throwing
I am using FullCalendar and populate the calendar from an ajax call. But I
I'm using a jQuery ajax call to get several entries from a large set
I'm using global variables to pass around a response from a AJAX call: window.response
I am using System.Linq.Dynamic to do custom where clauses from an ajax call in
I am calling a php function using ajax call but its not working. I
I am fetching data from a URL using an AJAX call. It is giving
I have created an IHttpAsyncHandler that I'm trying to call using AJAX, with jQuery.
I am making ajax call using ASP.NET 3.5 to populate dropdown list as a
I am using ajax call's to perform POST and GET operations from a WebService

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.