繁体   English   中英

从JavaScript函数将PHP发布到MySql-db

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM