鍍金池/ 問答/網(wǎng)絡(luò)安全  HTML/ 阿里大于 短信 注冊驗證 ajax返回數(shù)據(jù)的問題

阿里大于 短信 注冊驗證 ajax返回數(shù)據(jù)的問題

使用阿里大于的sdk做注冊時的手機(jī)驗證碼發(fā)送.
前臺ui頁面

    <label for="examplephone">手機(jī)號:</label>
    <input name="phone" type="text" class="form-control" id="examplephone" placeholder="手機(jī)號碼">
    <button class="btn btn-default" type="button" onclick="sendphone()">發(fā)送驗證碼</button>
    
    <script type="text/javascript">
            function sendphone(){
                // 獲取input的值
                $phone=$('#examplephone').val();
                $.ajax({
                    url:"api_demo/SmsDemo.php?phone="+$phone,
                    type:"get",
                    // 返回數(shù)據(jù)類型
                    dataType:'json',
                    success:function(res){
                       console.log(res);
                    }
                });
            }
        </script>

SmsDemo.php文件的代碼:

session_start();
$phone=$_GET['phone'];
$code=mt_rand(100000,999999);
$_SESSION['code']=$code;
$response = SmsDemo::sendSms(
    "xxx", // 短信簽名
    "xxx", // 短信模板編號
    $phone, // 短信接收者        
    Array(  // 短信模板中字段的值
        "code"=>$code,
        "product"=>"dsd"
    ),
    "123"   // 流水號,選填
);
print_r($response);
if($response->Message=="OK"){
    echo json_encode(["status"=>1,"message"=>"success"]);
}else{
    echo json_encode(["status"=>0,"message"=>"error"]);
}

從network中看到response數(shù)據(jù)為{status=1,message=>'success'},但是為什么consle.log(res);語句控制臺里看不到任何數(shù)據(jù).

回答
編輯回答
玩控

單詞寫錯了,應(yīng)該是:

console.log(res);
2017年12月28日 07:37