![](/img/trans.png)
[英]How to send error/success message through ajax without click submit button in form (if there isn't form) laravel?
[英]How to do AJAX call and PHP through submit button without form especially jQuery code
我想在數據庫代碼中了解更多jQuery,提交按鈕如何傳遞值ID?
HTML按鈕
<button id="primaryTextButton" value="submit" class="k-primary" style="float:right; padding: 5px 20px; border-radius: 4px;">Submit</button>
我想進行AJAX調用的Javascript
$(document).ready(function () {
dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "./getTest.php",
type: "POST",
data: function() {
return {
method: "getTemplate",
positionTemplateID: document.getElementById('positionTemplateID').value,
// hrsPositionID: dropdownlist.value(),
}
}
},
template: {
url: "./getTest.php",
type: "POST",
data: function () {
return {
method: "getTemplate",
employeeID: document.getElementById('employeeID').value,
propertyID: document.getElementById('propertyID').value,
}
},
complete: function (e) {
$('#grid').data('kendoGrid').dataSource.read();
}
},
},
schema: {
model: {
id: "positionTemplateID",
}
},
});
PHP在編碼數據庫中查詢
function getTemplate() {
$positionTemplateID = (isset($_POST['positionTemplateID']) ? $_POST['positionTemplateID'] : '');
$hrsPositionID = (isset($_POST['hrsPositionID']) ? $_POST['hrsPositionID'] : '');
$programID = (isset($_POST['programID']) ? $_POST['programID'] : '');
$propertyID = (isset($_POST['propertyID']) ? $_POST['propertyID'] : '');
$employeeID = (isset($_POST['employeeID']));
我得到的輸出
這里是演示的鏈接: https : //dojo.telerik.com/IYEvALiY/6
但是,提交按鈕不起作用。 我要提交的按鈕的功能是將復選框中的選定節點ID發布到數據庫中。
這就是通常使按鈕在jQuery中進行Ajax調用的方式
$( "#primaryTextButton" ).click(function(e){ e.preventDefault(); //so the page won't reload when you submit //make the ajax call });
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.