1:Ext.Ajax.request,配置web.config后返回的是json.
2:Ext.data.HttpProxy({url:""})返回的是json的吗?
function Btn_Search()
{
var div=document.getElementById("EditTable");
div.innerHTML="";
Ext.Ajax.request({
url:'WebService.asmx/GeneralList',
method:'POST',
jsonData:{UserName:""},
//headers:{'Content-Type':'application/json;utf-8'},
success:General,
failure:On_Error
});
}
{name: 'UserID', type: 'string'},
{name: 'LogonName', type: 'string'} ,
{name: 'UserName', type: 'string'},
{name: 'Password', type: 'string'},
{name: 'dtDateTime', type: 'string'}
]);
var data=Ext.util.JSON.decode(result.responseText);
//alert(result.responseText);
//先看返回的result.responseText是不是json,如果是,就用data.d来取数据
var store=new Ext.data.Store({
proxy:new Ext.data.MemoryProxy(data.d), //先看返回的result.responseText是不是json,如果是,就用data.d来取数据
reader:new Ext.data.JsonReader({
fields:[{name:'UserID',type:'int'},
{name:'LogonName',type:'string'},
{name:'UserName',type:'string'},
{name:'Password',type:'string'},
{name:'dtDateTime',type:'string',dateFormat:'Y-m-d'},
{name:'Email',type:'string'}
]})
});
// store.load();
//var record=store.getAt(0);
//alert(record.get("dtDateTime"));
web.config需要配置
<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<appSettings/>
<connectionStrings/>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="false">
<assemblies>
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></assemblies></compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add path="*.asmx" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
validate="false" />
<add path="*_AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
validate="false" />
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
<webServices>
<protocols>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
</configuration>