lundi 7 mai 2018

Can't Get AJAX to django

My HTML is like this:

$.ajax({
    type: "GET",
    url:"/ajax/validate_supplier/",
    data:{
        'supplier_name': supplier_name
    },
    dataType: 'json'
});

My django url is this one:

   path('ajax/validate_supplier/', views.validate_supplier, name='validate_supplier'),

And my view is this:

def validate_supplier(request):
    supplier_name= request.GET.get('supplier_name',none)
    data={
        'name_is': supplier_name
    }
    return JsonResponse(data)

This simple ajax get is not working for me, what am I doing wrong?

Aucun commentaire:

Enregistrer un commentaire