0
我有一個「特殊」AJAX請求的問題。我有一個表單與幾個組合(「選擇」標籤)。我從MySQL數據庫加載每個組合的項目,併爲我設計了一個特殊類。每個組合都有一個「+」按鈕(用於打開彈出窗口並添加新條目)。當用戶「保存」新值時,AJAX請求應該運行,但沒有任何事情發生。嗯,另一個細節:當新值被保存在數據庫中時,彈出窗口會自動關閉。如何在JS Popup中創建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> </p>
<p> </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>© </em></strong>Todos los Derechos Reservados 2010- -</span></p>
</th>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
Ajax請求768,16重載組合中的 「家長表格」 ,以及BD的所有條目(包括新的條目)。
我的問題是,我可以在彈出窗口中執行AJAX請求嗎?或者我該如何做到這一點?
在此先感謝!
PS:對不起我的英文,我不是「母語人士」。
是的,就是這樣。有效!非常感謝! – 2010-10-20 14:55:42