其實我不是js開發者。獲取元素有一些問題(select.value) 我的瀏覽器說:未捕獲ReferenceError:getprice未定義JS(jQuery) - 未定義
正如我所瞭解的,jquery可以通過id select.value獲取元素。我該如何解決它? 謝謝!
JS代碼:
function getprice() {
$.ajax({
type: "POST",
url: "<?=Core_Config::$Link?>store/cart",
data: {
pay_type: $("#pay_type").val();,
delivery_type: $("#delivery_type").val();,
totalprice: "<?=$total?>"
},
success: function(html) {
$("#content22").html(html);
}
});
}
HTML:
<tr>
<td><span class="required">*</span> Delivery:</td>
<td>
<select name="address[delivery]" id="delivery_type">
<? foreach ($this->db->query($this->delivery) as $delivery): ?>
<option value="<?=$delivery['id']?>"><?=$delivery['name']?> (<?=$delivery['cost']?> грн)</option>
<? endforeach; ?>
</select>
</td>
</tr>
<tr>
<td><span class="required">*</span> Payment:</td>
<td>
<select name="address[paytype]" id="pay_type" onchange="getprice();">
<? foreach ($this->db->query($this->payType) as $paytype): ?>
<option value="<?=$paytype['id']?>"><?=$paytype['name']?> (<?=$paytype['cost']?> грн)</option>
<? endforeach; ?>
</select>
</td>
</tr>
你確定你用用getPrice功能,本網站中加入腳本? –
@PiotrCzarnecki javascript總是暴露給客戶端的用戶(現在我們不要談論節點),所以我沒有反對意見 –
@Thomas - 我不明白你的意思,基本上我只是問是否包含這個腳本。也許它沒有被包含在HTML或捆綁包等 –