简体   繁体   English

MVC2路由+ Ajax ==?

[英]MVC2 Routing + Ajax ==?

Im touching up an mvc2 application thats nearly complete, I have some ajax requests that end up looking alot like 我正在整理一个几乎完成的mvc2应用程序,我有一些ajax请求最终看起来像

www.host.com/site/controller/action?UserName=asdf&UserPassword=asdfasdf&Email=asd%40df.com&PhoneNumber=541-345-5433&CompanyName="sdf" www.host.com/site/controller/action?UserName=asdf&UserPassword=asdfasdf&Email=asd%40df.com&PhoneNumber=541-345-5433&CompanyName="sdf“

So my question is how (if possible) can I mask the ajax url on the redirect to simply be.. /controller/action, Im getting the feeling I broke pattern with my ajax and am stuck with nasty URLS. 所以我的问题是,如何(如果可能的话)如何将重定向上的ajax URL屏蔽成简单的../controller/action,我感到我用我的ajax破坏了模式并陷入了讨厌的URLS。

any mvc2 gurus out there willing to clarify? 愿意澄清的任何MVC2专家吗?

Assuming you are using jquery try this: 假设您正在使用jQuery,请尝试以下操作:

 $.ajax({ url: '/controller/action';, data: { UserName: 'asdf', UserPassword: 'asdfasdf', Email: 'asd%40df.com', PhoneNumber: '541-345-5433', CompanyName: 'sdf' }, success: function(req, status, error) { updateSucceeded(); }, error: function(req, status, error) { updateFailed(error); } }); 

Be happy and enjoy life. 要快乐,享受生活。

First things first, I would say never send a password through a URL variable. 首先,我要说的是永远不要通过URL变量发送密码。 They're totally sniffable even if you're using HTTPS. 即使您使用的是HTTPS,它们也完全可以监听。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM