How can I make an ajax query in a fiddler with an example data?

0

Is there a page to do this?

Where you can insert variable datos and copy the url in query ajax .

Or where data can be used as the data of ajax , which I do not know if it is possible.

With what purpose do I do this? to test fiddlers with data in a url or data in a variable.

$( document ).ready(function() {
    ObtenerFunciones();
});
    
function ObtenerFunciones() {
    $.ajax({
        type: 'post',
        global: false,
        url: 'perfiles/getFunciones',
        data: {},
        success: function(data) {
            console.log(data);
        },
        error: function(data) {
            console.debug(data);
        }
    });
};

var datos = [
  {
    "id": 1,
    "id_padre": 0,
    "icono": "fa fa-dashboard fa-fw",
    "link": "/",
    "titulo": "Tablero"
  },
  {
    "id": 2,
    "id_padre": 0,
    "icono": "fa fa-tasks fa-fw",
    "link": "#",
    "titulo": "Procesos"
  },
  {
    "id": 3,
    "id_padre": 2,
    "icono": "fa fa-list-ol fa-fw",
    "link": "/lotes",
    "titulo": "Lotes"
  },
  {
    "id": 4,
    "id_padre": 2,
    "icono": "fa fa-eraser fa-fw",
    "link": "/limpieza",
    "titulo": "Limpieza"
  },
  {
    "id": 5,
    "id_padre": 2,
    "icono": "fa fa-stop fa-fw",
    "link": "/paradasopera",
    "titulo": "Paradas"
  },
  {
    "id": 6,
    "id_padre": 2,
    "icono": "fa fa-wrench fa-fw",
    "link": "#",
    "titulo": "Mantenimiento"
  },
  {
    "id": 7,
    "id_padre": 6,
    "icono": "fa",
    "link": "/planes",
    "titulo": "Planes"
  },
  {
    "id": 8,
    "id_padre": 6,
    "icono": "fa",
    "link": "/calendario",
    "titulo": "Calendario"
  },
  {
    "id": 9,
    "id_padre": 0,
    "icono": "fa fa-file-text-o fa-fw",
    "link": "#",
    "titulo": "Reportes"
  },
  {
    "id": 10,
    "id_padre": 9,
    "icono": "fa fa-bar-chart-o fa-fw",
    "link": "/estadisticos",
    "titulo": "Estadisticos"
  },
  {
    "id": 11,
    "id_padre": 9,
    "icono": "fa fa-building-o fa-fw",
    "link": "/estaticos",
    "titulo": "Estaticos"
  },
  {
    "id": 12,
    "id_padre": 9,
    "icono": "fa fa-file fa-fw",
    "link": "/parametrizados",
    "titulo": "Parametrizados"
  },
  {
    "id": 13,
    "id_padre": 0,
    "icono": "fa fa-wrench fa-fw",
    "link": "#",
    "titulo": "Opciones"
  },
  {
    "id": 22,
    "id_padre": 13,
    "icono": "fa fa-industry fa-fw",
    "link": "#",
    "titulo": "Marcas de<br/>Equipos"
  },
  {
    "id": 23,
    "id_padre": 22,
    "icono": "fa",
    "link": "/marcas",
    "titulo": "Marcas"
  },
  {
    "id": 24,
    "id_padre": 22,
    "icono": "fa",
    "link": "/modelos",
    "titulo": "Modelos"
  },
  {
    "id": 32,
    "id_padre": 13,
    "icono": "fa fa-clock-o fa-fw",
    "link": "/turnos",
    "titulo": "Turnos"
  },
  {
    "id": 14,
    "id_padre": 13,
    "icono": "fa fa-flask fa-fw",
    "link": "#",
    "titulo": "Productos<br/>de Elaboración"
  },
  {
    "id": 25,
    "id_padre": 14,
    "icono": "fa",
    "link": "/productos",
    "titulo": "Productos"
  },
  {
    "id": 26,
    "id_padre": 14,
    "icono": "fa",
    "link": "/unidadesdemedicion",
    "titulo": "Unidades de<br/>Medición"
  },
  {
    "id": 15,
    "id_padre": 13,
    "icono": "fa fa-arrows-alt fa-fw",
    "link": "#",
    "titulo": "Areas y Procesos<br/>de Producción"
  },
  {
    "id": 30,
    "id_padre": 15,
    "icono": "fa",
    "link": "/areas",
    "titulo": "Areas"
  },
  {
    "id": 31,
    "id_padre": 15,
    "icono": "fa",
    "link": "/procesos",
    "titulo": "Procesos "
  },
  {
    "id": 16,
    "id_padre": 13,
    "icono": "fa fa-steam fa-fw",
    "link": "#",
    "titulo": "Registro<br/>de Equipos"
  },
  {
    "id": 27,
    "id_padre": 16,
    "icono": "fa",
    "link": "/equipos",
    "titulo": "Equipos"
  },
  {
    "id": 28,
    "id_padre": 16,
    "icono": "fa",
    "link": "/partes",
    "titulo": "Partes"
  },
  {
    "id": 29,
    "id_padre": 16,
    "icono": "fa",
    "link": "/subpartes",
    "titulo": "Subpartes"
  },
  {
    "id": 17,
    "id_padre": 13,
    "icono": "fa fa-user fa-fw",
    "link": "/personas",
    "titulo": "Personas"
  },
  {
    "id": 18,
    "id_padre": 0,
    "icono": "fa fa-gears fa-fw",
    "link": "#",
    "titulo": "Configuración"
  },
  {
    "id": 19,
    "id_padre": 18,
    "icono": "fa fa-users fa-fw",
    "link": "/usuarios",
    "titulo": "Usuarios"
  },
  {
    "id": 20,
    "id_padre": 18,
    "icono": "fa fa-suitcase fa-fw",
    "link": "/perfiles",
    "titulo": "Perfiles"
  },
  {
    "id": 21,
    "id_padre": 18,
    "icono": "fa fa-database fa-fw",
    "link": "/respaldo",
    "titulo": "Respaldo"
  }
]
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    
asked by Pablo Contreras 24.04.2017 в 00:37
source

2 answers

0

Here on this website we can place a json to use it in a ajax of any fiddler. Example:

$('select').select2({
    placeholder: "Elija...",
    allowClear: true,
    ajax: {
    	type: "GET",
        dataType: 'json',
        url: 'https://api.myjson.com/bins/12apr1',
        delay: 250,
        data: function(params) {
            return {
	            term: params.term, // search term
	            page: params.page || 1, //page number
            }
        },
	    processResults: function (data, page) {
	        return {
                results: $.map(data.results, function (n) {
                    return {
                        text: n.text,
                        children: n.children
                    }
                }),
	            pagination: {
	                more: data.pagination.more,
	            }
	        };
	    },
        cache: true
    },
    escapeMarkup: function (markup) { return markup; },
    templateResult: crear_marca_modelo_formatData,
    templateSelection: crear_marca_modelo_formatDataSelection
});
function crear_marca_modelo_formatData (data) {
	if (data.loading) return data.text;
	return data.text;
}
function crear_marca_modelo_formatDataSelection (data) {
	let labelOptg = $(data.element).parent().attr('label');
	return labelOptg + " / " + data.text;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2/js/select2.min.js"></script>

<select style="width: 100%"></select>
    
answered by 11.05.2017 / 23:58
source
0

In order to do what you say you should have an application on a public server that responds to your requests, something like this:

function ObtenerFunciones() {
$.ajax({
    type: 'post',
    global: false,
    url: 'http://www.muyserver.com/perfiles/getFunciones',
    data: {},
    success: function(data) {
        console.log(data);
    },
    error: function(data) {
        console.debug(data);
    }
});

};

If it helps to obtain the data of an object, you do not need the AJAX request, use that object directly.

function ObtenerFunciones() {
    console.log(datos);
});

Another option is to use one of the public APIs that some services have available, for example Tumblr:

https://savedbythe-bellhooks.tumblr.com/api/read/json

You can use the blog address you want, and add /api/read/json at the end.

    
answered by 26.04.2017 в 17:58