2012-10-23 25 views
-1

當我在我的jQuery網址中使用它找到;問題jQuery的ResolveClientUrl asp.net

$.ajax({ 
           url: '<%= ResolveClientUrl("~/TestJQueryTabStrip.aspx/DeleteRecord") %>', 
           type: "POST", 
           dataType: "json", 
           contentType: "application/json; charset=utf-8", 
           data: JSON.stringify({ id: itemId }) 
          }); 

但是當我想改變這個;

url: '<%= ResolveClientUrl("~/UserControls/Order/OrderProductLicense.aspx/DeleteRecord") %>', 

它找不到。我該如何解決這個問題?

問候

+0

路徑問題。 orderproductlicense.aspx中的方法也是deleterecord?也許其他參數? –

+0

檢查我的更新回答 –

+0

是否在orderProductLicense.aspx。但我認爲url does not find.cause相同的代碼運行在testjuqery.aspx – emozguner

回答

0

我喜歡這個..

public static class MyUtility 
{ 

public static string GetAppPath() 
    { 

     return (System.Web.HttpRuntime.AppDomainAppVirtualPath == "/") ? string.Empty : System.Web.HttpRuntime.AppDomainAppVirtualPath; 

    } 
} 

然後在jQuery的參考像JavaScript變量

var myOrderUrl=<%= MyUtility.GetAppPath() %>+'/UserControls/Order/OrderProductLicense.aspx/DeleteRecord'; 

$.ajax({ 
      url: myOrderUrl, etc.. 
+0

感謝您的答案,但問題仍然存在。我如何解決它 – emozguner