当我们已经拥有MVC提供的默认功能时,为什么我们需要ajax / jquery调用colntroller方法? [英] Why do we need ajax/jquery calling for colntroller method when we already have default functionality given by MVC?

查看:159
本文介绍了当我们已经拥有MVC提供的默认功能时,为什么我们需要ajax / jquery调用colntroller方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设在示例应用程序中有一个SUBMIT按钮,并且在FORM标签中我已经设置了POST方法。所以当我点击提交按钮时,它会自动执行各自控制器的动作。这个id已经存在于MVC中。那么为什么我们需要AJAX或者jQuery用于相同的目的,即调用各自控制器的动作?



我知道Ajax调用是异步的,但除了其他任何优点之外?



我尝试了什么:



我知道AJAX异步行为,但我们不要总是这样,在这种情况下我们该怎么做?

Suppose in a sample application there is a SUBMIT button, and in FORM tag I've alreasdy set POST method. So when I click on submit button it'll automatically execute respective controller's action. This id already there in MVC. Then why do we need AJAX or jQuery for the same purpose, i.e. calling respective controller's action?

I know Ajax call would be asynchrounous, but other than that any other advantage?

What I have tried:

I know about AJAX asynchronous behaviour but we don't want it always, in that case what should we do?

推荐答案

如果你不想重新加载页面,那么Ajax就是解。您可以将数据发送到服务器并在没有回发的情况下执行所有操作。
If you don't want to reload the page, then Ajax is the solution. You can send data to server and do everything without a post back.


这篇关于当我们已经拥有MVC提供的默认功能时,为什么我们需要ajax / jquery调用colntroller方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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