S
S
Sedbol2019-08-24 08:39:50
AJAX
Sedbol, 2019-08-24 08:39:50

Explain why this happens and how to solve AJAX?

I send a request to the database:

$.ajax({
        url: "roomUser/YouTubeBase.php",
        type: "POST",
        dataType: "JSON",
        data: {YouTubeBase: count},
        success: function (BootYouTube) {
            console.info(BootYouTube)
        }
    });

The count variable is equal to 0 The request does not work if I send it without To 0, the server comes to the server And it does not work with the JSON string. On the server like this:dataType: "JSON",
if($_POST['YouTubeBase']) {
//БЛА...бла...бла
}

POST does not work when I send 0, if 1 then everything works fine, how to make it work even with 0

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
irishmann, 2019-08-24
@Sedbol

Because in this case if($_POST['YouTubeBase']) = false.
Use another way like
if (isset($_POST['YouTubeBase'])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question