dongpo5264 2016-03-03 13:16
浏览 378
已采纳

如何在不刷新整个页面的情况下从不同页面获取数据

I have two page first one is packagebuilder.php then second one is hotel.php. I have to pass data from packagebuilder.php to hotel.php. hotel.php is caring table of hotel list and that list i want to show in the packagebuilder.php


packagebuilder.php enter image description here

this is input section when i put all the detail in the form then click on the submit button then only hotel list section should be refresh with the hotel list of item in the table not the whole page

<div>
  <select id="Country" class="dropdown">
    <option value="">Select</option>
    ...
  </select>
  <select id="Destination" class="dropdown">
    <option value="">Select</option>
    ...
  </select>
  <input type="date" name="checkin" id="name" placeholder="Date" required/>
  <input type="date" name="checkout" id="name" placeholder="Date" required/>
  <input type="text" name="hotel" id="hotel" placeholder="Hotel... Optional" required/><br/><br/>
  <select id="room" class="dropdown">
    <option value="">Select</option>
    ...
  </select>
  <select id="adult" class="dropdown">
    <option value="">Select</option>
    ...
  </select>
  <select id="child" class="dropdown">
    <option value="">Select</option>
    ...
  </select>
  <select id="infant" class="dropdown">
    <option value="">Select</option>
    ...
  </select>
  <select id="ratingmin" class="dropdown">
    <option value="">Select</option>
    ...
  </select>
  <select id="ratingmax" class="dropdown">
    <option value="">Select</option>
    ...
  </select>
  <input type="submit" id="submit" name="submit" value="Submit" class="button"> 
  <br/><br/>
</div>

  • 写回答

3条回答 默认 最新

  • dongzhenshen7435 2016-04-17 00:00
    关注

    try to use this

    <script src="https://code.jquery.com/jquery-1.10.2.js"></script>
    <script type="text/javascript">
         $(document).ready(function() {
             $('#submit').click(function() {
                var country_id =  $("select#ddlcountry option:selected").attr('value');
                var dest_id =  $("select#ddldest option:selected").attr('value');
                var rooms_val =  $("select#ddlroom option:selected").attr('value');
                var adult_val =  $("select#ddladult option:selected").attr('value');
                var child_val =  $("select#ddlchild option:selected").attr('value');
                var infant_val =  $("select#ddlinfant option:selected").attr('value');
                var rtmin_val =  $("select#rtmin option:selected").attr('value');
                var rtmax_val =  $("select#rtmax option:selected").attr('value');
                var checkin =  $("#checkin").val();
                var checkin =  $("#checkout").val();
                var checkin =  $("#hotel").val();
    
                var datastring = { 
                    "ddlcountry":country_id,
                    "ddldest":dest_id,
                    "checkin":checkin,
                    "checkout":checkout,
                    "hotelname":htmane,
                    "ddlroom": rooms_val,
                    "ddladult":adult_val,
                    "ddlchild":child_val,
                    "ddlinfant":infant_val,
                    "rtmin":rtmin_val,
                    "rtmax":rtmax_val, 
                }
                $.ajax({
                    type: "POST",
                    url: "hotel.php",
                    data: datastring,
                    cache: false,
                    success: function(html) {    
                        $('.result').html( html );
                    }                       
                });
             });
        });
    </script>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog