Failed to load resource: the server responded with a status of 500 Internal server error

0
function addRow(data) {
    var tabla = $("#tbl_temas").DataTable();
    for (var i = 0; i < data.length; i++) {
        tabla.fnAddData([
            data[i].idTema,
            data[i].idAdministrador,
            data[i].tituloTema,
            data[i].descripcion,
            data[i].pdf,
            data[i].imagen,
            ((data[i].estado == true)?"Activo":"Inactivo")
        ]);

    }
}
function sendDataAjax() {
    $.ajax({
        type: "POST",
        url: "frmGestionarTemas.aspx/listarTema",
        data: {},
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        error: function (xhr, ajaxOptions, throwError) {
            console.log(xhr.status + "\n" + xhr.responseText, "\n" + throwError);
        },
        success: function (data) {

            addRow(data.d);
        }

    });
}

sendDataAjax();

ASP Method

[WebMethod]
    [ScriptMethod(UseHttpGet =true)]
    public static List<Temas> listarTema() {
        List<Temas> lista = new List<Temas>();

        try
        {
            lista = TemaN.getInstance().listaTemas();
        }
        catch (Exception ex) {
            lista = null;
        }

        return lista;
    }
    
asked by Eduardo Duffaut Molina 06.11.2017 в 09:12
source

1 answer

1

This error tells you that an error has occurred in the server code.

From what I can see of your code you define a WebMethod indicating that it should be called using HTTP GET ( ScriptMethod(UseHttpGet = true) ) while in the Ajax call you use the POST method:

function sendDataAjax() {
  $.ajax({
    type: "POST",

If after changing this you still get an error message you should try to run the debugging website.

    
answered by 06.11.2017 в 09:22