$.ajax({
type: "POST",
url: "DataImport.aspx/InsertInitialFile",
contentType: "application/json; charset=utf-8",
processData: false,
data: '{"companyId":"' + "1" + '","importFileName":"' + "license.txt" + '","filePath":"' + "UploadFolder\Initial\Temprahullate" + '","importStatusId":"' + "5" + '"}',
//data: '{"companyId":"' + companyId + '","importFileName":"' + importFileName + '","filePath":"' + filePath + '","importStatusId":"' + importStatusId + '"}',
dataType: "json",
success: function (Msg) {
$("#<%= upload_Initialfilename.ClientID %>").val("");
$("#<%= ddlCompany.ClientID %>").val("0");
$('#<%= lblMessage.ClientID %>').html("File saved successfully.");
$("#<%= lblMessage.ClientID %>").css("color", "Green");
},
error: function (Msg) {
console.log(Msg);
alert('error');
}
});
我正在尝试使用 jquery ajax 调用 web 方法的代码。当我像上面的代码一样手动发布静态数据时,它的工作正常
data: '{"companyId":"' + "1" + '","importFileName":"' + "license.txt" + '","filePath":"' + "UploadFolder\Initial\Temprahullate" + '","importStatusId":"' + "5" + '"}',
但真正的问题是,当我在服务器端检查filePath
字段数据时,它会从其中删除斜杠。意味着代替这个UploadFolder\Initial\Temprahullate
我进入UploadFolderInitialTemprahullate
服务器端方法。
我需要那些斜杠,因为那是文件夹的路径。