jQuery中的路径Ajax功能不起作用 [英] Path in jQuery Ajax Function not working

查看:98
本文介绍了jQuery中的路径Ajax功能不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!



我在弄清楚我在画布上双击的网页路径时遇到了问题。



网页在一个文件夹中,我一直在尝试很多路径来访问该网页,但我找不到正确的网页。



Hi!

I'm having problems figuring out the path of the web page where I'm inserting a double click on a canvas.

The web page is in a folder, and I have been trying alot of paths to access that webpage but I can't find the correct one.

function dblClick(e) {
           canvas = document.getElementById("myCanvas");
           var newX = e.x - canvas.offsetLeft;
           var newY = e.y - canvas.offsetTop;
           $.ajax({
               type: "POST",
               url: "../Admin/CreateMap.aspx/DoubleClick()",
               data: JSON.stringify({ x: newX, y: newY }),
               contentType: "application/json; charset=utf-8",
               dataType: "json",
               success: function (data) {
                   eval(data.d);
               },
               error: function (msg) {
                   alert(msg);
               }
           });





这是我的剧本。有什么帮助?



This is my script. Any help?

推荐答案

.ajax({
type: POST
url: ../ Admin / CreateMap。 aspx / DoubleClick()
数据: JSON .stringify({x:newX,y:newY}),
contentType: application / json; charset = utf-8
dataType: json
成功: function (数据){
eval (data.d);
},
错误: function (msg){
alert(msg);
}
});
.ajax({ type: "POST", url: "../Admin/CreateMap.aspx/DoubleClick()", data: JSON.stringify({ x: newX, y: newY }), contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { eval(data.d); }, error: function (msg) { alert(msg); } });





这是我的剧本。任何帮助?



This is my script. Any help?


url: "../Admin/CreateMap.aspx/DoubleClick()",





只需写



just write

url: "../Admin/CreateMap.aspx/DoubleClick",


而不是使路径相对于jscript文件,使其相对到你的URL的根文件夹或使用ResolveURL。



请参阅这篇文章关于ASP.NET中ResolveURL的替代方案... ASP.NET中的ResolveUrl - 完美解决方案 [ ^ ]
Instead of making the path relative to the jscript file, make it relative to the root folder of your URL or use ResolveURL.

See this article about an alternative for ResolveURL in ASP.NET ... ResolveUrl in ASP.NET - The Perfect Solution[^]


这篇关于jQuery中的路径Ajax功能不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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