Last active
November 27, 2017 18:03
-
-
Save ccbenavides/98cc6db688e41af6e46aa05ac82f72a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
$('#albumSubmit').submit(function(e){ | |
e.preventDefault(); | |
var ambito = this; | |
console.log(this); | |
$.ajax({ | |
url: '{{ route("admin.albums.store") }}', | |
method: 'post', | |
dataType: 'JSON', | |
data: { | |
'tipo' : $("#tipoMetodoAlbum").val(), | |
'identificador' : $("#identificadorAlbum").val(), | |
'name': $('#nombreAlbum').val(), | |
'description': $('#descripcionAlbum').val(), | |
'_token': '{{csrf_token()}}' | |
}, | |
success: function(data){ | |
if(data.name){ | |
if(data.metodo == "put"){ | |
$("#albumItem_" + data.id).html(` | |
<a href="#" class="album_enlace"> | |
<i class="ti ti-folder"></i> | |
<p>${data.name}</p> | |
</a>`); | |
alert('Actualizado con éxito'); | |
} | |
if(data.metodo == "post"){ | |
$("#albumContent").append(` | |
<div class="col-sm-2 album_div" id="albumItem_${data.id}}"> | |
<a href="#" class="album_enlace"> | |
<i class="ti ti-folder" id="albumSeleccionado"></i> | |
<p id="albumSeleccionado">${data.name}</p> | |
</a> | |
</div>`); | |
alert('creado con éxito'); | |
} | |
ambito.reset(); | |
$("#modalAlbum").modal('hide'); | |
} | |
}, | |
error : function(data){ | |
console.log(data); | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment