0
/* EXCLUIR ARQUIVOS DA GALARIA */
$(document).ready(function() {
/* EXCLUI ARQUIVOS DA GALERIA IMG E PDF */
$( "#btnexcluipdf" ).bind( "click", function() {
var vID = $('#idarquivopdf').val();
//alert(vID);
//$("#status").html(
// "ID excluido: ");
var vurl = '?pg=excluirarquivo';
var vData = {id:vID};
$.ajax(
vurl
,vData
,function(response,status){
if(status == "sucess")
{
var obj = jQuery.parseJSON(response);
$("#status").html(
"ID excluido: " + obj.id );
}
}
);
});
php...
<?php
header('Content-type: application/json; charset=utf-8');
var_dump($_POST);
//$id = $_POST["id"];
?>
deixei o codigo assim.
/* EXCLUIR ARQUIVOS DA GALARIA */
$(document).ready(function() {
/* EXCLUI ARQUIVOS DA GALERIA IMG E PDF */
$( "#btnexcluipdf" ).bind( "click", function() {
$.ajax({
method: "POST"
,url: document.location.pathname + '?pg=excluirarquivo'
,data: { id: $('#idarquivopdf').val() }
,dataType: "html"
})
.done(function( resposta ) {
alert(resposta);
}).fail(function(jqXHR, textStatus) {
alert("Erro:" + textStatus);
}).always(function() {
alert("OK");
});
});
when clicking, the event (Alert(reply);) shows an html page, then it goes through the done and shows nothing, but reaches the end in OK.
Alter
bind
foron
and$.ahax
for$.ajax
– NoobSaibot
AJAX parameters must be in JSON. I recommend to read documentation
– Valdeir Psr
Also enjoy and read .bind() that in the version 3.0 was discontinued, and to learn more about .on().
– NoobSaibot
wmsouza , had already adjusted, I posted wrong, but still does not enter the ajax, I can give Alert before then but does not enter the.
– Jefferson Meireles
$.ajax({ url: vurl, data: vData
... See the documentation link @Valdeirpsr passed!– NoobSaibot
vurl
not a valid link, if sending to the same page, usevar vurl = document.location.pathname + '?pg=excluirarquivo';
. The address has to have apath
valid.– balexandre
balexandre, thanks for the tip, but I do not know what happens, I can not find out pq not enough in php..
– Jefferson Meireles
/* DELETE FILES FROM GALARIA / $(Document). ready(Function() { / DELETE GALLERY FILES IMG AND PDF */ $( "#btnexcluipdf" ).bind( "click", Function() { $. ajax({ method: "POST" ,url: Document.location.pathname + '?pg=deleterquiver' ,data: { id: $('#idarquivopdf'). val() } ,dataType: "html" }) . done(Function( answer ) { Alert(answer); }). fail(Function(jqXHR, textStatus) { Alert("Error:" + textStatus); }). Always(Function() { Alert("OK"); }); });
– Jefferson Meireles
<?php header('Content-type: application/json; charset=utf-8'); var_dump($_POST); //$id = $_POST["id"];
– Jefferson Meireles