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 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?