question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

abp.jquery.ajax can't display error message

See original GitHub issue

Hi. I’m using abp.jquery to send a ajax request.now,I remove admin role from swagger ui,then can return a message “Static roles can not be deleted.”,this is correct.if I using abp.jquery.ajax to send it .this will return “An error has occurred! Error detail not sent by server.”,I think problem is here.

    return $.Deferred(function ($dfd) {
            $.ajax(options)
                .done(function (data, textStatus, jqXHR) {
                    if (data.__abp) {
                        abp.ajax.handleResponse(data, userOptions, $dfd, jqXHR);
                    } else {
                        $dfd.resolve(data);
                        userOptions.success && userOptions.success(data);
                    }
                }).fail(function (jqXHR) {
                    //problem here.
                    if (jqXHR.responseJSON && jqXHR.responseJSON.__abp) {
                        abp.ajax.handleResponse(jqXHR.responseJSON, userOptions, $dfd, jqXHR);
                    } else {
                        abp.ajax.handleNonAbpErrorResponse(jqXHR, userOptions, $dfd);
                    }
                });
        });

How can I return a correct message from abp.jquery.ajax?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
SinoMilescommented, Apr 28, 2017

Follow code is my ajax request

page.DeleteRole = function () {
   //if not select any row. return flase
    if (Cobject.BrowserGrid.getSelectedRowObj() == null) {
        $.ligerDialog.warn("必须选择一行!");
        return false;
    }
   //this is a ligerui confirm Dialog
    $.ligerDialog.confirm('确定删除?', function (yes) {
        if (yes)
        {
            var id = Cobject.BrowserGrid.getSelectedRow().id;
            var para = {
                "id": id
            };
            abp.ajax({
                url: '/api/services/app/role/DeleteRole',
                data: JSON.stringify(para)
            }).done(function (data) {
                Cobject.BrowserGrid.loadData();
                Message("删除成功");
            });
        }
    });
}

if I remove admin or user ,.here will define an error.(“An error has occurred! Error detail not sent by server.”)

                   //problem here.
                    if (jqXHR.responseJSON && jqXHR.responseJSON.__abp) {
                        abp.ajax.handleResponse(jqXHR.responseJSON, userOptions, $dfd, jqXHR);
                    } else {
                        //
                        abp.ajax.handleNonAbpErrorResponse(jqXHR, userOptions, $dfd);
                    }

F12 check chrome-devtools network xhr will find DeleteRole request. 1 2 chinese message is “Static roles can not be deleted”,here is correct , but then will show this error,I want to diaplay “Static roles can not be deleted” 3

1reaction
hikalkancommented, Apr 27, 2017

Can you write your code here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

jquery - AJAX error message not displayed (success ...
I am setting up a add/remove dynamic input field using JQUERY/AJAX. I am a beginner with coding and this is my first time...
Read more >
ASP.NET Core MVC / Razor Pages UI JavaScript AJAX API
abp.ajax API provides a convenient way of performing AJAX calls to the server. It internally uses JQuery's $.ajax, but automates some common tasks...
Read more >
jQuery.ajax()
A set of key/value pairs that configure the Ajax request. All settings are optional. A default can be set for any option with...
Read more >
abp.ajax
As you can see, success is false and result is null. abp.ajax handles this object and shows an error message to the user...
Read more >
Returning Server-Side Errors from AJAX Calls
Here's the simplest way to integrate custom server-side error messages with your jQuery AJAX calls.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found