简体   繁体   English

在ajax数据中发送存储过程

[英]Send stored procedure in ajax data

I need send stored procedure with parameter in ajax data. 我需要在ajax数据中使用参数发送存储过程。

Below is my example, after send get this error 以下是我的示例,发送后出现此错误

Apostrophes real problem,any solution? 使徒真正的问题,有什么解决办法?

function sendData(userNameVal, procedureNameVal, jsonCallBackFunc) {
    var stringVal = "wsInsertData N'EXECUTE carInsert N''160655'',N''data:image/png;base64,AAAAAAAAAAAA'',N''18602''', N'18602'";

     $.ajax({
                    type: "POST",
                    url: 'helloService.asmx/myService',
                    data: "{userName:\"" + userNameVal + "\",procedureName:\"" + stringVal + "\",callback:\"" + jsonCallBackFunc + "\",}",

                    dataType: 'json',
                    contentType: 'application/json; charset=utf-8',
                    success: function (response) {
                        $('#lblError').html(JSON.stringify(response));
                    },
                    error: function (error) {
                        console.log(error);
                    }
                });
            }

Security! 安全! All it takes is a user to edit the JSON response to the server and add their own SQL, and they can make your SQL server do anything they want. 用户只需要编辑对服务器的JSON响应并添加自己的SQL,他们就可以使您的SQL Server做他们想要的任何事情。 Pass whatever parameters you need, and have the server construct the Stored Proc after sanitizing possible crazy inputs from the client. 传递所需的任何参数,并在清除客户端可能的疯狂输入后让服务器构造存储过程。

在“回调”之前,添加单引号“,该引号不会终止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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