4
Accurate, when returning from an insert pass parameter to a page and load it into a div specific, I tried something like this:
var formData = new FormData(this);
$.ajax({
url: formURL,
type: 'POST',
data: formData,
mimeType: "multipart/form-data",
contentType: false,
cache: false,
processData: false,
success: function(data, textStatus, jqXHR) {
var json = $.parseJSON(data);
var IdContrato = json.par;
// TABELA COM DOCUMENTOS DO CONTRATO
$("#resultado-upload").load('pListaUpload.php',{IdContrato:IdContrato});
// LIMPANDO CAMPOS DO FORMULÁRIO
$("#sObservacao").val("");
},
error: function(jqXHR, textStatus, errorThrown) {
$("#resultado-upload").html('<pre><code class="prettyprint">REQUISIÇÃO AJAX FALHOU<br/> textStatus=' + textStatus + ', errorThrown=' + errorThrown + '</code></pre>');
}
});
e.preventDefault();
e.unbind();
The page php which searches the data and should be shown is this:
// Array que irá retornar o status da execução do script (JSON)
$aretorno = array();
$aretorno["msg"] = "";
$aretorno["status"] = "";
@$conn = new mysqli($DBServer, $DBUser, $DBPass, $DBName);
// Checar conexão
if ($conn->connect_errno) {
$aretorno["msg"] = "Conexão ao banco de dados falhou.";
$aretorno["status"] = "ERRO";
echo $aretorno;
exit;
}
if (!$conn->set_charset("utf8")) {
$aretorno = "Erro ao carregar conjunto de caracteres utf8.";
echo $aretorno;
exit;
}
$sql = "SELECT * FROM gerDoctoContrato WHERE IdContrato = ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param(
"i",
$_POST["IdContrato"]
);
if($stmt->execute()){
$data = array();
$result = $stmt->get_result();
echo '';
echo '
Arquivo
Tipo
Caminho
Ação
';
echo '';
while ($row = $result->fetch_assoc()) {
$IdDocumento = $row['IdDocumento'];
$IdContrato = $row['IdContrato'];
echo '';
echo '' . $row['NomeArquivo'] .'';
echo '' . $row['TipoArquivo'] .'';
echo '' . $row['CaminhoAnexo'] .'';
echo '';
echo '';
}
echo '';
echo '';
$stmt->close();
}else{
echo "Ocorreu um erro na listagem dos dados: " . $stmt->error . ". Verifique.";
}
//close the database
$conn->close();
And on my return it appears Array, the parameter was able to recover but display the table not.
you already have the value of Idcontrato ? and just are not able to load the table, this ?
– Thiago Friedman
Hi @Thiago Friedman, that’s right.
– adventistapr