Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var urlWs = "http://localhost:55555/api/articulos/";
- $(document).ready(function(){
- $('#form').submit(function(e){
- var libro = $('#libro').val();
- $.ajax({
- type: "GET",
- contentType: "application/json",
- dataType: "json",
- url: urlWs + "?libro=" + libro,
- async: false,
- cache: false,
- crossDomain: true,
- success: function(data){
- if(data['Articulo'].IdArticulo !== 0){
- var $myList = $( "#myList" );
- $($myList).empty();
- var nuevoLi = $('<li>');
- $(nuevoLi).text(data['Articulo'].Descripcion + ' (' + data.CantidadDisponible + ') (' + data['Bodega'].Descripcion + ')');
- $($myList).append(nuevoLi);
- } else {
- alert('No hay datos para el libro buscado');
- }
- /*
- console.log(data);
- var msj = "";
- $.each(data, function (index, value) {
- msj = msj + value.IdArticulo + ' - ' + value.Descripcion + ' - ' + value.Paginas;
- //$("#tbContenido").append("<tr><td>" + value.IdArticulo + "</td><td>"
- // + value.Descripcion + "</td><td>"
- // + value.Paginas + "</td></tr>");
- });
- window.location.reload();
- if(msj == "")
- alert("No existen datos");
- else
- alert(msj);
- */
- },
- error: function (xhr, ajaxOptions, thrownError) {
- alert("Error: " + xhr.status + "\n" +
- "Message: " + xhr.statusText + "\n" +
- "Response: " + xhr.responseText + "\n" + thrownError);
- }
- });
- return false;
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement