V
V
Vladimir2017-05-06 20:09:17
JavaScript
Vladimir, 2017-05-06 20:09:17

How to pass boolean parameter in AJAX?

How to pass a boolean type parameter to the server, when passing the parameter, a string arrives at the server. the variable status - type boolean (checked through typeof)
is a trace. request

$.ajax({
        type: 'POST',
        url: '/TODOList/'+status,
        data: params,
        success: function (req, res) {
            if(status == true){
                $target.attr('checked', true);
            }else  {
                $target.removeAttr('checked');
            }
            console.log(status);
            //location.reload();
        },
        error: function (errоr) {
            console.log(error);
        }
    });

On the server, a line arrives in req.params.status, this is logical, but how to pass the bool value there? you need to write to the database, a line is written and everything breaks ...) Thank you

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dark Hole, 2017-05-06
@zhuravlev125

Erm... has StackOverflow been cancelled?
stackoverflow.com/questions/7408976/bool-parameter...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question