jquery.load()无效(不重定向到另一个页面)

时间:2015-12-17 04:37:00

标签: javascript php jquery html load

我有一个关于公司数据信息的网页。有搜索并添加新按钮。当我们单击选择Custtype页面中的Add New按钮时,有一个select option,其中包含分支和客户模型。在我们点击button save之前,我们必须首先选择分支和客户模型。选择并单击button save后,将重定向到数据表单页面。这是我选择的_custtype.php代码:

<?php
   session_start();
   require_once('global.php');
   $where_in = '';
   if( isset($_SESSION['moi_status_UserBranch']) && trim($_SESSION['moi_status_UserBranch'])!="" ){
     $xubranch = explode(",",$_SESSION['moi_status_UserBranch']);
     if( count($xubranch)>0 ){
       $mxt = array();
       foreach($xubranch as $r){
         $mxt[] = "'".$r."'";
       }
       $where_in = implode(",",$mxt);
     }
   }
?>

<!DOCTYPE html>
<html>
   <head>
      <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
      <title>Order</title>
      <link rel="stylesheet" href="template/css/validationEngine.jquery.css" type="text/css"/>
      <link rel="stylesheet" href="lib/jqueryui/css/ui-lightness/jquery-ui-1.8.21.custom.css" type="text/css" />
      <link rel="stylesheet" href="template/css/mytheme.css" type="text/css"/>

      <script src="template/js/jquery-1.6.min.js" type="text/javascript></script>
      <script src="lib/jqueryui/js/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>
      <script src="template/js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
      <script src="template/js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
      <script src="template/js/jquery.imask.js" type="text/javascript ></script>
   </head>
   <body>
   <b>Choose Branch and Customer Model</b>
   <br /><br />
   <form id="search" class="formular" method="post" action="choose_custtype.php" style="z-index:1;">
   <table width="100%">
       <tr>
          <td width="110">Branch</td>
          <td>
              <select id="ownergroupid" name="ownergroupid" class="readonly validate[required]"><option value="">-- CHOOSE --</option>
                 <?php $code = $db->GetOne("SELECT OWNERGROUPID FROM FNTLOANAPPLICATION WHERE DATAID = '".$_GET['id']."'");
                       $branch = $db->GetAll("SELECT CAB_ID, CABANG_NAME FROM COMPANY_PROFILE WHERE CAB_ID IN (".$where_in.") ORDER BY CABANG_NAME ASC");
                       foreach($branch as $k => $v) { ?>
                        <option value="<?php echo $v[0];?>" <?php echo $v[0]==$code?"selected":"";?>><?php echo $v[1];?></option>
                 <?php  } ?>
              </select>
          </td>
      </tr>
      <tr>
          <td width="110">Customer Model</td>
          <td>
              <select id="customer_model" name="customer_model" class="readonly validate[required]">
                 <option value="">Choose</option>
                 <option value="I">Personal</option>
                 <option value="C">Corporate</option>
             </select>
          </td>
      </tr>
   </table>
   <input type="submit" id="btnsubmits" name="btnsubmit" class="button" value="Save" />
   <?php //echo "aaaa"; ?>
   </form>
   <script>
      $('#btnsubmits').click(function(e){
        e.preventDefault();
        if ($('#ownergroupid').val() == ''){
           alert('Branch must fill!');
        }else if ($('#customer_model').val() == ''){
           alert('Customer Model must fill!');
        }else
        search.submit();
     });
    </script>

    <?php if (@$_POST['customer_model']): ?>
    <?php 
       $_SESSION['customer_model_new'] = ($_POST['customer_model']); 
       $_SESSION['ownergroupid_new'] = ($_POST['ownergroupid']); 

       //echo "aaaa";
    ?>
    <script type="text/javascript">
       window.opener.location.href = "index.php";
       //window.opener.document.location.href = "index.php";
       window.close();
    </script>
    <?php endif; ?>
 </body>
</html>

这是我的index.php

<?php
   session_start();
   require_once('global.php');

   //echo "test";
?>
<!DOCTYPE html>
<html>
   <head>
      <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
      <title>Pooling Order</title>
      <link rel="stylesheet" href="template/css/validationEngine.jquery.css" type="text/css"/>
      <link rel="stylesheet" href="lib/jqueryui/css/ui-lightness/jquery-ui-1.8.21.custom.css" type="text/css" />
      <link rel="stylesheet" href="template/css/mytheme.css" type="text/css"/>

      <?php //echo "test2"; ?>
      <script src="template/js/jquery-1.6.min.js" type="text/javascript"></script>
      <script src="lib/jqueryui/js/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>
      <script src="template/js/languages/jquery.validationEngine-en.js" type="text/javascript" charset="utf-8"></script>
      <script src="template/js/jquery.validationEngine.js" type="text/javascript" charset="utf-8"></script>
      <?php //echo "test3"; ?>
      <script src="template/js/jquery.imask.js" type="text/javascript"></script>

      <?php //echo "test4"; ?>
      <script>
         jQuery(document).ready(function(){
            $('#formlist').load('data_form.php?dataid=<?php echo $_GET['dataid']; ?>&customer_model=<?php echo $_GET['customer_model']; ?>&ownergroupid=<?php echo $_GET['ownergroupid']; ?>');
         });
      </script>

      <?php //echo "test5"; ?>
   </head>

   <body>
      <table width="100%" height="">
         <tr>
            <td align="right">
               <!--<input type="button" id="list" name="list" class="button" value=" List " />-->
               <!-- <input type="button" id="form" name="form" class="button" value=" Form " />-->
               <div id="form"></div>
            </td>
         </tr>
      </table>
      <div id="formlist"></div>
   </body>
</html>

正如我们从代码中看到的,在我们选择分支和客户模型后,页面将重定向到index.php,然后data_form.php. data_form.php是一个输入数据的表单。但是,data_form.php无法加载。是因为来自index.php的jquery / javascript吗?我怀疑它:

<script>
   jQuery(document).ready(function(){
      $('#formlist').load('data_form.php?dataid=<?php echo $_GET['dataid']; ?>&customer_model=<?php echo $_GET['customer_model']; ?>&ownergroupid=<?php echo $_GET['ownergroupid']; ?>');
   });
</script>

以前我使用php 5.2及其工作,但不是php 5.5(我将PHP 5.2升级到5.5)。这是因为语法不同吗? (在PHP 5.5中不兼容)

0 个答案:

没有答案