Measure the test taker's knowledge about how to improve AJAX performance.

Source: Internet
Author: User
AJAX: describes how to improve AJAX performance.

In Web forms, AJAX is used to call the server method from the client (through JavaScript), while XMLHttpRequest is called within AJAX. I tested some AJAX functions implemented in different ways. In addition, I also monitored and analyzed the performance and lifecycle of AJAX calls. As a result, I found some serious problems when using AJAX in Web forms. However, I also found a solution to these problems. In this article, I want to analyze this problem and its corresponding solutions.

Ii. performance problems encountered when using AJAX

For every AJAX call, we need to create an instance of classes containing AJAX methods. In addition, if we use the new keyword at the class level, we also need to create instances for fields, attributes, and other class-level variables.

Iii. Implementation Scheme

I created a project that contains two Web forms: WebForm1.aspx and WebForm2.aspx, and a class of Student. vb. Both code-behind pages use an AJAX function getData () and a public variable of the Student type. With the help of the MXLogger class, I recorded the execution process of each stage.

Note: The AJAX function GetData () of Webform2.aspx is shared, but it is not shared in WebForm1.

'Student. vb
Public Class Student
Sub New ()
MXLogger. AddLog ("From Student. Constructor ")
End Sub
Dim _ Name As String
Public Property Name () As String
Get
Return _ Name
End Get
Set (ByVal Value As String)
_ Name = Value
End Set
End Property
End Class

'Webform1. aspx. vb
Public Class WebForm1
Public Student As New Student
Sub New ()
MXLogger. AddLog ("From WebForm1.Constructor ")
End Sub
_
Public Function getData () As String
MXLogger. AddLog ("From WebForm1.Ajax. getData ()")
Return "I m a Non Shared Function"
End Function
End Class
'Webform2. aspx. vb
Public Class WebForm2
Public Student As New Student
Sub New ()
MXLogger. AddLog ("From WebForm2.Constructor ")
End Sub
_
Public Shared Function getData () As String
MXLogger. AddLog ("From WebForm2.Ajax. getData ()")
Return "I m a Shared Function"
End Function
End Class

 

[1] [2] Next page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.