SORU
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ş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • The CGBros

    The CGBros

    20 AĞUSTOS 2011
  • Trulia

    Trulia

    29 Kasım 2006
  • tunez4you

    tunez4you

    20 EKİM 2008