我有一个“特殊” Ajax请求的问题。我有一个带有多个连击的表格(“选择”标签)。我正在从MySQL DB中加载每个组合的项目,并为我设计了一个特殊的课程。每个组合都有一个“+”按钮(用于打开弹出窗口并添加新条目)。当用户“保存”新值时,AJAX请求应运行,但是什么也不会发生。啊,另一个细节:当它保存在数据库中的新值时,弹出窗口会自动关闭。

这是弹出代码(PHP):

<?php
  require ("class\BD.php");
  require ("class\combos.php");
  require ("xajax/xajax_core/xajax.inc.php");
  $Conex = new BD();
  if (isset($_POST['GuardarTipoSist']))
  {
   $Ajax = new xajax();
   function cargarTipoSistema()
   { 
     $Combo = new combos();
     $Combo->setParams('cobTipo',$Conex);
     $Contenido = $Combo->CargarCombo();
     $AjaxResponse = new xajaxResponse();
     $AjaxResponse->assign("cobTipo","innerHTML",$Contenido);
   }
    $Ajax->registerFunction("cargarTipoSistema");
    $TipoSist = $_POST['txtTipoSist'];
    $Query = "INSERT INTO Tipos_Sistemas VALUES(NULL,'$TipoSist')";
    $Conex->query($Query);
    $Ajax->processRequest();
    echo '<script>alert("Guardado Correctamente"); return true; window.close();</script>';
  }
?>

这是HTML代码:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <title>Ingresar Tipo Sistema - GESPROGAN</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
    <style type="text/css">
    <!--
    .Estilo2 {
        font-size: 16px;
        color: #827BCC;
    }
    .Estilo12 {
        color: #FFFFFF;
        font-size: 10px;
        font-weight: bold;
        font-style: italic;
    }
    -->
    </style></head>
    <script type="text/javascript" language="javascript" src="validaciones.js"></script>
    <body>
    <table width="390" height="270" border="1">
      <tr>
        <td bordercolor="#F0F0F0" background="images/dominios tipo sistema.png" width="380" height="264"><p>&nbsp;</p>
        <p>&nbsp;</p>
        <form name="DomTipoSist" action="dominios_tipo.php" method="POST" onsubmit="return validarIngDatHac(); return true;">
        <table width="371" height="166" border="1" align="center">
          <tr>
            <th width="361" height="160" scope="col"><p class="Estilo2">POR FAVOR INGRESE EL NUEVO TIPO DE SISTEMA </p>
              <table width="341" height="68" border="1">
                <tr>
                  <td height="27" colspan="2">
                    <input id="txtTipoSist" name="txtTipoSist" type="text" size="55"/>
                  </td>
                  </tr>
                <tr>
                  <td width="162" height="33">
                    <div align="center">
                      <input id="GuardarTipoSist" name="GuardarTipoSist" type="submit" value="GUARDAR"/>
                    </div>
                  </td>
                  <td width="163">
                    <div align="center">
                      <input id="Cancelar" name="Cancelar" type="button" value="CANCELAR" onclick="javascript:window.close()"/>
                    </div>
                  </td>
                </tr>
              </table>          
              <p class="Estilo2"><span class="Estilo12"> - GESPROGAN.. <strong><em>&copy; </em></strong>Todos los Derechos Reservados 2010- -</span></p>          
            </th>
          </tr>
        </table>  
        </form>    
       </td>
      </tr>
    </table>
    </body>
    </html>

Ajax请求将组合重新加载在“父型”中,并带有BD的所有条目(包括新的)。

我的问题是,我可以在弹出窗口中执行Ajax请求吗?还是我该怎么做?

提前致谢!

PS:对不起,我的英语,我不是“讲母语的人”。

有帮助吗?

解决方案

在不在弹出窗口中的主窗口中运行AJAX请求。因此,例如,当您在弹出窗口中提交表单时,请执行window.opener.cargartiposistema();

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top