October 22, 2024
Chicago 12, Melborne City, USA
PHP

Can I convert this code php to JavaScript?


I need to convert these lines of code to javascript somehow, can you guys help me ?
(Let me explain what trying to do since you might be wondering this is SoapClient service for hotels to check their client’s id)

try 
  {
    //Cant change the left side of the const because of the SoapClient
    $inputs = array(
    "TCKimlikNo" => $IDN,
    "Ad" => $NAME,
    "Soyad" => $SURNAME,
    "DogumYili" => $BIRTH
    );

    $connect = new SoapClient('https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL');
    $result = $connect->TCKimlikNoDogrula($inputs);

    if ($result->TCKimlikNoDogrulaResult){
    echo 'IDN correct';
    }
    else 
    {
    echo 'IDN incorrect';
    }
  }
catch (Exception $hata)
{
echo '! IDN is not available';
}

WHAT I TRIED :
I got "ReferenceError: SoapClient is not defined" error. This can be custom error message because I couldn’t find the same error on the internet

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>ID Inquiry</title>
</head>
<body>
<form>
<input type="button" onclick="fnc()" value="submit" />
<script>
    function fnc()
    {
        try
        {
            let IDN = parseFloat("");
            //I actually put real info here
            const NAME = "";
            const SURNAME = "";
            const DateOfBirth = "";
            
            const inputs = 
            {
                TCKimlikNo: IDN,
                Ad: NAME,
                Soyad: SURNAME,
                DogumYili: DateOfBirth
            };

            const soapClient = new SoapClient('https://tckimlik.nvi.gov.tr/Service/KPSPublic.asmx?WSDL');
            const resultt = soapClient.IDquestioning(inputs);

            if (resultt.IDquestioningResult) {
                alert('correct');
            } else {
                alert('incorrect');
            }

        } catch (error) {
            alert(error);
        }
    }
</script>
</form>
</body>
</html>

I know this is hard to help (probably) bc since you are not from my country you are not gonna be able to test. But if you have any idea to help I would be very grateful



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video