27 Aralık 2013, Cuma
Bir anahtar olmadığını kontrol json bir nesne içinde var
amt: "10.00"
email: "sam@gmail.com"
merchant_id: "sam"
mobileNo: "9874563210"
orderID: "123456"
passkey: "1234"
Yukarıdaki hangi merchant_id anahtarı eğer,eğer,eğer varsa, kontrol etmek istiyorsanız aşağıdaki kodu denedim, ama çalışmıyor json nesne.bunu başarmak için her neyse?
<script>
window.onload = function getApp()
{
var thisSession = JSON.parse('<?php echo json_encode($_POST); ?>');
//console.log(thisSession);
if (!("merchant_id" in thisSession)==0)
{
}
else
{
alert "yeah";
}
</script>
CEVAP
27 Aralık 2013, Cuma
Bu deneyin
if(thisSession.hasOwnProperty('merchant_id')){
}
JS thisSession
gibi olmalı Nesne
{
amt: "10.00",
email: "sam@gmail.com",
merchant_id: "sam",
mobileNo: "9874563210",
orderID: "123456",
passkey: "1234"
}
ayrıntılar here bulabilirsiniz
Bunu Paylaş:
Belirli bir anahtar olmadığını kontrol...
Eğer nesne JavaScript içinde olup olma...
Anahtar olmadığını kontrol etmek için ...
Nasıl bir nesne olarak Symfony2 Twig ş...
Eğer bir nesne zaten Varlık Çerçevesi ...