简体   繁体   中英

How to send error response to ajax in python django?

I have ajax call:

$.ajax({
        type: "POST",
        url: "../getFormMetaData/",
        cache:false,
        data: $data,
        success: createZoomDialog,
        error:function(response){

        }
    });

how can I send data to ajax error handler from python django?

You can return HttpResponse with a 4xx error code in your view:

def view(request):
    return HttpResponse("error", status=404)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM