Im not able to send data to view due json serializable

i am getting error set object is not JSON serializable i also used json.dumps but still getting this error ? actually i am trying to save form data to django database with help of ajax but where i am doing mistake

    def update_ajax(request):
       if request.method == "GET" and request.is_ajax():
          nam1 = request.GET.get('nam1')
          nam2 = request.GET.get('nam2')
          nam3 = request.GET.get('nam3')
          n1 = json.loads(nam1)
          n2 = json.loads(nam2)
          n3 = json.loads(nam3)
          print(n1, n2, n3)
    return JsonResponse({'success'}, safe=False)

script

function myfun(){
    let nam1=document.getElementById('name').value;
    let nam2=document.getElementById('email').value;
    let nam3=document.getElementById('phone').value;

    obj ={
        'nam1': JSON.stringify(nam1),
        'nam2':JSON.stringify(nam2),
        'nam3':JSON.stringify(nam2),
    }
    

    $.ajax({
        type:"GET",
        url: "{% url 'update_ajax' %}",
        dataType: "json",
        data:   obj, 
        
        success:function(){
            alert('success')
        }
        
    });

}
Back to Top