[英]Post PHP to MySql-db from JavaScript function
我有一個JavaScript函數(href鏈接)可以打開模式窗口,並且我想從該函數/窗口中將其發送到包含大約四個PHP函數的PHP頁面(box.php); 其中之一是“ check_box”,用於檢查其他三個功能。 有沒有辦法做到這一點,或者JavaScript無法/不支持它? 這就是我所擁有的:
PHP頁面:
<a href="javascript:openModal()" title="" style="padding-right: 10px;">LEAVE</a>
PHP代碼:
<?php
echo $class->box->check_box() ?>
JavaScript函數:
function openModal()
{
$.modal({
content:
/* This where the content of the modal window goes */
title: 'Outside the workplace',
width: 300,
scrolling: false,
actions: {
'Close' : {
color: 'red',
click: function(win) { win.closeModal(); }
},
'Center' : {
color: 'green',
click: function(win) { win.centerModal(true); }
},
'Refresh' : {
color: 'blue',
click: function(win) { win.closeModal(); }
},
'Abort' : {
color: 'orange',
click: function(win) { win.closeModal(); }
}
},
buttons: {
'Close': {
classes: 'huge blue-gradient glossy full-width',
click: function(win) { win.closeModal(); }
}
},
buttonsLowPadding: true
});
};
創建一個將執行插入操作的php頁面。 從該PHP的瀏覽器中解析參數並執行插入。 然后輸出一條消息。 在JavaScript中以指定的DIV
顯示消息-類似於以下內容(修復值並將參數傳遞給函數):
function setToDatabase() {
jQuery(function($) {
$.ajax( {
url : "submittosql.php?valuetosubmit=NEWVALUE",
type : "GET",
success : function(data) {
document.getElementById("YOURDIV").innerHTML=data;
}
});
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.