PDA

View Full Version : [CLOSED] Help on proxy exception JS error



cleve
Jun 11, 2012, 7:45 AM
Hi guys, please help me on the following code



<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server"></head>
<body id="theBody">
<ext:ResourceManager ID="theManager" runat="server" IDMode="Inherit" Theme="Default"
EnableViewState="false" DisableViewState="true" ShowWarningOnAjaxFailure="false"
ScriptMode="Debug" />
<ext:Store runat="server" ID="s" AutoLoad="false">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="ItemName" />
<ext:ModelField Name="ItemValue" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
<ext:Button runat="server" Text="Test" Scale="Medium">
<Listeners>
<Click Handler="testFunc();" />
</Listeners>
</ext:Button>
<script language="javascript" type="text/javascript">

var exProcess = function (proxy, response, operation) {
window.alert(response.responseText);
}
var testFunc = function () {
var store = <%= s.ClientID %>;
store.load();
}
</script>
<form runat="server" id="theForm" />
</body>
</html>
<script runat="server">

protected override void OnInit(EventArgs e)
{
AjaxProxy ajaxProxy = new AjaxProxy() { Url = "/test.aspx/getexception" };
ajaxProxy.ActionMethods.Read = HttpMethod.POST;
ajaxProxy.Listeners.Exception.Fn = "exProcess";
ajaxProxy.Reader.Add(new JsonReader() { Root = "data", TotalProperty = "total" });
s.Proxy.Add(ajaxProxy);
}
</script>



The MVC action code is as the this:




public AjaxResult GetException()
{
return new AjaxResult()
{
ErrorMessage = "Exception found."
};
}



I encounter a JS error when dispose the alert window (screenshot is attached). Any ideas?

Daniil
Jun 11, 2012, 9:59 AM
Hi,

Please set up

MessageProperty = "message"
for the JsonReader.

Also please use StoreResult instead of AjaxResult. StoreResult is designed for AjaxProxy.