1
我正在使用Twilio客戶端應用程序,而且我很難發送DTMF音調。這裏是我到目前爲止的代碼:Twilio客戶端DTMF不工作
<script type="text/javascript">
$.each(['0','1','2','3','4','5','6','7','8','9','star','pound'], function(index, value) {
$('#button' + value).click(function(){
if(connection) {
if (value=='star')
connection.sendDigits('*')
else if (value=='pound')
connection.sendDigits('#')
else
connection.sendDigits(value)
return false;
}
});
});
</script>
<div id="dialpad">
<table>
<tr>
<td><input type="button" value="1" id="button1"></td>
<td><input type="button" value="2" id="button2"></td>
<td><input type="button" value="3" id="button3"></td>
</tr>
<tr>
<td><input type="button" value="4" id="button4"></td>
<td><input type="button" value="5" id="button5"></td>
<td><input type="button" value="6" id="button6"></td>
</tr>
<tr>
<td><input type="button" value="7" id="button7"></td>
<td><input type="button" value="8" id="button8"></td>
<td><input type="button" value="9" id="button9"></td>
</tr>
<tr>
<td><input type="button" value="*" id="buttonstar"></td>
<td><input type="button" value="0" id="button0"></td>
<td><input type="button" value="#" id="buttonpound"></td>
</tr>
</table>
</div>
當我打電話給我的測試號碼,再按撥號盤上的按鈕不發送的值。任何幫助,這是非常感謝?
嗨,只是讀的JavaScript提供目前尚不清楚你在任何地方初始化'connection'變量。另外,您是否可以使用console.log確認當您單擊任何輸入時,each()函數實際上正在執行? –