存储会话以获取json响应 [英] store session for json response

查看:92
本文介绍了存储会话以获取json响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对带有查找按钮的视图提出了搜索请求.当单击按钮时,我在Json中有它的响应,并且在同一视图上有一个提交按钮.所以搜索在同一视图中请求它的json响应和一个提交,现在当我单击提交"按钮时,它会转到另一个控制器的另一个视图,在该视图中,我有一个后退按钮,该按钮必须返回我的搜索页面,该页面上应显示搜索和json响应.为此,我需要存储搜索请求和即将到来的json响应.我在javascript中具有json响应.因此,当我单击后退"按钮时,如何按顺序存储搜索请求和json响应以显示请求和响应.使用MVC3 razor

i have a search request on a view with a find button. when the button clicked i have its response in Json, and a submit button on the same view.So the search request its json response and a submit on the same view,now when i click the submit button it goes to another view of different controller,and in that view i have a back button which has to come back to my search page, where it should show the search and the json response. For this i need to store the search request and the json response coming..i have the json response in javascripts. So how do i store the search request and the json response in-order to show the request and response when i click the back button. using MVC3 razor

推荐答案

您的问题标题非常正确:会话是一个选择,cookie是另一个选择.但这取决于您对"json响应"的处理方式.假设它是一个简单的文本值.
处理搜索ajax操作时,将结果存储在会话中.呈现该视图时,请使用会话值恢复结果.使用Cookie,您可以执行相同的操作,只是使用javascript并在客户端进行.
如果结果更复杂,则必须决定如何有效地存储它...
You are perfectly right in your question title: session is one option, cookie is an other. But it depends on what you have done with your "json response". Let''s suppose it is a simple text value.
When handle the search ajax action, store the result in the session. When you render that view, use the session value to restore the result. With cookie you do quite the same, just with javascript and on client side.
If the result is more complex, you have to decide how to store it efficiently...


这篇关于存储会话以获取json响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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