1
我被阿賈克斯從母版試圖調用的方法沒有成功的Ajax調用:從母版與WebService的
母版
$(function ListaCategorias() {
var pageUrl = '<%=ResolveUrl("~/WebService/MenuEsquerdo.asmx")%>';
$.ajax({
type: "POST",
url: pageUrl + '/ListaCategoriasMenu',
data: "{}",
contentType: "application/json; charset=utf-8",
dataTyle: "json",
async: false,
error: function (jqXhR, textStatus, errorThrown) { alert(errorThrown); },
success: function (data) {
var Categorias = data.d;
var counter = 0;
aCategorias = [];
//Carrega as Categorias
$.each(Categorias, function (index, categorias) {
aCategorias[counter] = [
categorias.cat_id, categorias.cat_descricao, categorias.cat_total_anuncios
];
counter++;
});
}
});
});
MenuEsquerdo.asmx
/// <summary>
/// Summary description for MenuEsquerdo
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class MenuEsquerdo : System.Web.Services.WebService
{
[WebMethod]
//[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static IList ListaCategoriasMenu()
{
tab_categorias tabCategorias = new tab_categorias { cat_ativo = true, cat_deletado = false };
var listCategorias = tabCategorias.ListaCategoriasMenu();
return listCategorias;
}
}
我剛剛得到的錯誤消息「內部服務器錯誤」。
我在做什麼錯?
我想加載一個菜單,我認爲在使用WebService,但如果你知道更好的選項,如事件處理程序,我是開放的頭腦。
謝謝。
UPDATE
我也tryied使用用戶控件,但返回的錯誤信息是Forbbiden!