使用ajax更新mvc中的局部视图 [英] updating partial view in mvc using ajax

查看:58
本文介绍了使用ajax更新mvc中的局部视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在获取未被捕获的类型错误:无法读取未定义的属性ajax

这是我的代码:



I am getting uncaught type Error: cannot read property ajax of undefined
Here is my Code:

function test()
{
    $.ajax({
        url: '@Url.Action("drawInputs")',
        data: { QueryName: App.About.getValue() }
    })
    .done(function (result) {
        $('#SomeDiv').html(result);
    });
}







<td>@(Html.X().ComboBox().ID("About").Editable(false)
                                  .ValueField("ID")
                                     .DisplayField("Name")
                                    .Store(Html.X().Store()
                                    .Model(Html.X().Model()
                                    .IDProperty("ID")
                                    .Fields(
                                        new ModelField("ID", ModelFieldType.String) { Mapping = "ID" },
                                        new ModelField("Name", ModelFieldType.String) { Mapping = "Name" }
                                           )
                                         )
                               .Proxy(Html.X().AjaxProxy()
                                        .Url(Url.Action("GetEXTParams"))
                                        .Reader(Html.X().JsonReader().RootProperty("data"))
                                        )
                            )
                                        )
                        .Listeners(li => { li.Select.Handler = "test()"; })
                     )</td>





我在控制器操作结果中名为drawInputs,返回partialview



and I have in the controller action result named "drawInputs" that return partialview

推荐答案

.ajax({
url:' @ Url.Action( drawInputs)'
数据:{QueryName:App.About.getValue()}
})
.done(函数(结果){
.ajax({ url: '@Url.Action("drawInputs")', data: { QueryName: App.About.getValue() } }) .done(function (result) {


' #SomeDiv').html(result);
});
}
('#SomeDiv').html(result); }); }







<td>@(Html.X().ComboBox().ID("About").Editable(false)
                                  .ValueField("ID")
                                     .DisplayField("Name")
                                    .Store(Html.X().Store()
                                    .Model(Html.X().Model()
                                    .IDProperty("ID")
                                    .Fields(
                                        new ModelField("ID", ModelFieldType.String) { Mapping = "ID" },
                                        new ModelField("Name", ModelFieldType.String) { Mapping = "Name" }
                                           )
                                         )
                               .Proxy(Html.X().AjaxProxy()
                                        .Url(Url.Action("GetEXTParams"))
                                        .Reader(Html.X().JsonReader().RootProperty("data"))
                                        )
                            )
                                        )
                        .Listeners(li => { li.Select.Handler = "test()"; })
                     )</td>





我在控制器操作结果中名为drawInputs,返回partialview



and I have in the controller action result named "drawInputs" that return partialview


错误是我不包括jquery.js这就是为什么它会给出这样的错误。

谢谢你
the error was that I am not including jquery.js thats why it is giving such error.
thank you


这篇关于使用ajax更新mvc中的局部视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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