发送ajax数据中的存储过程

Send stored procedure in ajax data

本文关键字:存储过程 数据 ajax 发送      更新时间:2023-09-26

我需要在ajax数据中发送带有参数的存储过程。

下面是我的例子,发送后得到这个错误

撇号真的有问题,有解决方案吗?

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);
                    }
                });
            }

安全!用户只需编辑服务器的JSON响应并添加自己的SQL,就可以让SQL服务器做任何他们想做的事情。传递您需要的任何参数,并让服务器在清除客户端可能的疯狂输入后构造存储过程。

在"callback"之前,您添加了一个未终止的单引号。