boolean variables posted through AJAX being treated as strings in server side

前端 未结 4 1701
南方客
南方客 2020-12-03 00:41

Following is a part of an AJAX functionality to add classes and packs to session cart:-

The jquery part

function addClassToCart(item         


        
4条回答
  •  庸人自扰
    2020-12-03 01:18

    1. Send the data from your javascript as stringified JSON.
    2. Make a PHP function to convert the strings 'true' and 'false' to boolean value.

    Personally I like #2, which goes with Nick Craver's answer.

提交回复
热议问题