我们可以在JQuery中执行SQL查询吗 [英] Can we Execute SQL Queries in JQuery

查看:470
本文介绍了我们可以在JQuery中执行SQL查询吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以在jQuery Calllback函数&中执行mySQL查询吗?杂项功能

can we execute mySQL queries in jQuery Calllback functions & misc. functions

简单的查询

UPDATE EMPLOYEE SET PAY = PAY + 500 WHERE E_ID = '32'

推荐答案

最好的办法是向服务器发出AJAX请求,然后使用服务器端代码执行此查询.

The best thing you can do is to issue an AJAX request to a server and then execute this query using a server side code.

您可以在此使用 jQuery.post() 情况.

You can use jQuery.post() in this case.

编辑

Edit

要了解AJAX的概述,请阅读

To get an overview of AJAX Read this

阅读 以获得并概述AJAX方法jQuery.

Read this to get and overview of AJAX methods in jQuery.

在页面中编写服务器端逻辑以执行SQL命令.然后使用AJAX向该页面发出请求.

Write a server side logic to execute the SQL command, in a page. Then using AJAX issue a request to that page.

示例代码

$(function(){
    // Bind a click event to your anchor with id `updateSal`
    $("#updateSal").click(function(){
        // get your employeeID
        var empID = "32"; 
        // issue an AJAX request with HTTP post to your server side page. 
        //Here I used an aspx page in which the update login is written
        $.post("test.aspx", { EmpID: empID},
            function(data){
                // callack function gets executed
                alert("Return data" + data);
        });

        // to prevent the default action
        return false;
    });
});

这篇关于我们可以在JQuery中执行SQL查询吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆