简体   繁体   English

更新页面而不刷新它

[英]Update the Page without refresh it

Goal: 目标:
When you click on the row (1), new data shall display (3.) without the whole webpage will be updated/refreshed. 当您单击行(1)时,将显示新数据(3.),而整个网页不会被更新/刷新。

Problem: 问题:
1. 1。
I need advice and I don't know where to find the funciton to display the picture number 2 and how to display the data and new object (3.) without update/refresh the whole webpage? 我需要建议,我不知道在哪里可以找到显示图片编号2的功能以及如何显示数据和新对象(3.)而无需更新/刷新整个网页?

And

2 2
How do you create an icon to display loading picture? 如何创建显示加载图片的图标?

Information: 信息:
- The page is based on ASP.mvc with C# -该页面基于带有C#的ASP.mvc

在此处输入图片说明

Use ajax functionality of either jquery or MVC ajax helpers. 使用jquery或MVC ajax助手的ajax功能。

You can find jquery ajax here . 您可以在此处找到jquery ajax。

and MVC ajax helper lib here 和MVC ajax helper lib 在这里

and here 在这里

you can make an ajax call to the server's websevice and it can return one of the well known web format (for eg json or XML). 您可以对服务器的Web服务进行Ajax调用,它可以返回一种众所周知的Web格式(例如json或XML)。 When the webservice call returns you can then "inject" the data in your html page with either javascript (dom manipulation) or using MVC helpers. 当webservice调用返回时,您可以使用javascript(dom操纵)或使用MVC帮助器将数据“注入”到html页面中。

Here's one that could help.. http://www.asp.net/mvc/tutorials/older-versions/javascript/creating-a-mvc-3-application-with-razor-and-unobtrusive-javascript 这可能会有所帮助。.http ://www.asp.net/mvc/tutorials/older-versions/javascript/creating-a-mvc-3-application-with-razor-and-unobtrusive-javascript

使用ajax + PartialViews更新一些页面部分

You Can use jquery ajax which would call async action method(function). 您可以使用jquery ajax来调用异步操作方法(函数)。 Data is returned the form of Json. 数据以Json的形式返回。 You can write code to deserilize data and display it using jquery. 您可以编写代码来反序列化数据并使用jquery显示数据。 Create a Action method which would return JsonResult as viewresult as 创建一个Action方法,该方法将JsonResult作为viewresult返回为

public JsonResult GetJsonData()
{
 return Json(new
                    { testDataResult =TestDataResultObj.Data
                       JsonRequestBehavior
                    }, JsonRequestBehavior.AllowGet);
}

and write following jquery code:- if (GetDataAsyc()) { 并编写以下jquery代码:-如果(GetDataAsyc()){

                        $.ajax({
                            type: "GET",
                            data: { testData: testDataResult },
                            url: url,// url of action method to be called asynch
                            dataType: "json",
                            cache: false,
                            traditional: true,
                            contentType: "application/json",
                            success: function (data) {

                                   // on success assign  testDataResult to messages //line
                                    $("#MessagesLines").html(testDataResult .Html);

                                }
                            },
                            error: function () {
                                //Display error message
                                $("ErrorMsg").html("There was error whey trying to process your request") 
                            }
                        });
                    } 

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

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