Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How Ajax does not refresh the Url submission page

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail how Ajax does not refresh the Url submission page. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

With the popularity of frameworks such as Jquery,porotype,Ext, a lot of simplified code can be said to be a boon for programmers.

Freed from the heavy code work, it is easy to achieve the complex functions of writing in the past.

However, there are pros and cons. Up to now, programmers who are used to using various frameworks and seldom write their own internal source code still have a few basic codes that remember Ajax that are not really complex.

In order not to forget my original enthusiasm, I re-posted this basic code and reviewed it for myself.

one. For Ajax, determining the categories of browsers is a repetitive and nothing new task, and this code can be encapsulated and called at will.

The code is as follows:

Function xmlhttp ()

{

Var A=null

Try

{

A=new ActiveXObject ("Msxml2.XMLHTTP")

}

Catch (e)

{

Try

{

A=new ActiveXObject ("Microsoft.XMLHTTP")

}

Catch (oc)

{

If (typeof XMLHttpRequestrated = "Undefined")

{

A=new XMLHttpRequest ()

}

}

}

Return A

}

Do not explain, anyway, even if do not understand, directly copy the past is no problem.

two. Next is the code that submits the Url.

The whole process is more or less the same, most of the code can actually be encapsulated, as long as the parameters are passed in, and then get the result.

The code is as follows:

Function Ajax (url)

{

Var XmlHttp=new xmlhttp ()

Try

{

XmlHttp.open ("POST", url,true)

Var result=SendUrl ()

}

Catch (e)

{

Alert (e)

}

}

3.

The code is as follows:

Function SendUrl ()

{

XmlHttp.send ()

XmlHttp.onreadystatechange=function ()

{

If (XmlHttp.readyState==4 & & XmlHttp.status==200)

{

Var result=XmlHttp.responseText

Return result

}

}

}

This is the end of the article on "how Ajax does not refresh the Url submission page". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report