CN108536793A - A kind of method and system for preventing ajax requests from repeating to submit - Google Patents

A kind of method and system for preventing ajax requests from repeating to submit Download PDF

Info

Publication number
CN108536793A
CN108536793A CN201810280363.3A CN201810280363A CN108536793A CN 108536793 A CN108536793 A CN 108536793A CN 201810280363 A CN201810280363 A CN 201810280363A CN 108536793 A CN108536793 A CN 108536793A
Authority
CN
China
Prior art keywords
data
request
sessionstorage
url
parameter
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Withdrawn
Application number
CN201810280363.3A
Other languages
Chinese (zh)
Inventor
魏志伟
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhengzhou Yunhai Information Technology Co Ltd
Original Assignee
Zhengzhou Yunhai Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhengzhou Yunhai Information Technology Co Ltd filed Critical Zhengzhou Yunhai Information Technology Co Ltd
Priority to CN201810280363.3A priority Critical patent/CN108536793A/en
Publication of CN108536793A publication Critical patent/CN108536793A/en
Withdrawn legal-status Critical Current

Links

Landscapes

  • Information Transfer Between Computers (AREA)

Abstract

The present invention provides a kind of method and system for preventing ajax requests from repeating to submit, and the described method comprises the following steps:S101, url, parameter, record time and the current time for reading ajax requests to be sent, preserve into sessionstorage;S102, cleaning is timed to storage data according to storage time difference;S103, next ajax requests are compared and are stored to the url in sessionstorage, parameter, determine whether request sends according to comparison result.The present invention is preserved by the url and parameter that ask ajax to sessionstorage, by the record time and the current time that compare request to create, the automatic cleaning of data is made requests on according to the storage time of setting, and same request is searched whether in sessionstorage according to the url and parameter of request next time, to avoid request from repeating to send, solve the problems, such as that the double hit occurred when page interim card causes js to execute delay operation can cause to repeat to submit request, it can effectively avoid the page and frequently occur stuck situation, promote user experience.

Description

A kind of method and system for preventing ajax requests from repeating to submit
Technical field
The present invention relates to Internet communication technology fields, especially a kind of to prevent ajax requests from repeating the method submitted and being System.
Background technology
In web-page requests processing, button, when submitting demand, then asks resource to server, does not make to locate when the user clicks When reason, many requests are had after repeatedly clicking and are being waited for, it may appear that the problem of page interim card is even collapsed.
At this stage, the ajax request controls of Web page repeat the point that the method submitted generally initiates request button in order to control It hits, i.e., after sending out request, request button is forbidden clicking, again by the taboo of button after receiving response or after a period of time Removed with state, to restore normal, user can continue to click and send request.Specially when triggering ajax requests, change Become submitting button on word and button is set to click state, when ajax ask complete when, change submitting button on Word and button is set to click state.
But the problem of thus bringing, is inevitable and causes js to execute delay when page interim card, still will appear company Operation is hit, the problem of submitting data is duplicated.
Invention content
The object of the present invention is to provide a kind of method and systems for preventing ajax requests from repeating to submit, it is intended to which the page is worked as in solution The problem of double hit operation that interim card occurs when js being caused to execute delay can cause to repeat to submit request, effectively the page is avoided frequently to go out Existing stuck situation, promotes user experience.
To reach above-mentioned technical purpose, the present invention provides a kind of methods for preventing ajax requests from repeating to submit, including with Lower step:
S101, url, parameter, record time and the current time for reading ajax requests to be sent, preserve extremely In sessionstorage;
S102, cleaning is timed to storage data according to storage time difference;
S103, next ajax requests are compared and are stored to the url in sessionstorage, parameter, tied according to comparing Whether decisive and resolute fixed request sends.
Preferably, url, parameter, record time and the current time of the ajax requests to be sent are in the form of object The array being stored in sessionstorage.
Preferably, the storage time difference is the difference of current time and record time.
Preferably, the step S102 is specially:
Be arranged timing function, at regular intervals the period just obtain sessionstorage data;
Traverse record time and current time of the array per data, record storage time in sessionstorage data Difference;
When difference is greater than the set value between when stored, this request data in array is deleted;
Modified array is newly stored into sessionstorage.
Preferably, the step S103 is specially:
Sessionstorage data are obtained as data1;
When next ajax asks to create the XmlHttpRequest stages, read the url and parameter of the request, and by its As data2;
Each object in data1 is traversed, checks whether that there are the object datas that url and parameter are data2;
If it does, to repeat to submit, the request is abandoned;If it does not exist, then continuing to send request.
The present invention also provides a kind of systems for preventing ajax requests from repeating to submit, including:
Url and parameter memory module, for read the url of ajax to be sent request, parameter, the record time and it is current when Between, it preserves into sessionstorage;
The automatic cleaning modul of data is stored, for being timed cleaning to storage data according to storage time difference;
Judge request whether sending module, for comparing next ajax request and storing into sessionstorage Url, parameter determine whether request sends according to comparison result.
Preferably, url, parameter, record time and the current time of the ajax requests to be sent are in the form of object The array being stored in sessionstorage.
Preferably, the storage time difference is the difference of current time and record time.
Preferably, the automatic cleaning modul of the storage data specifically includes:
Request data timing acquisition unit, for timing function to be arranged, at regular intervals the period just obtain Sessionstorage data;
Storage time difference acquiring unit traverses the record time of the every data of array in sessionstorage data and works as Preceding time, record storage time difference;
Request data deleting unit when being greater than the set value for difference between when stored, deletes this request data in array;
Again storage unit, for modified array to be newly stored into sessionstorage.
Preferably, described to judge whether sending module specifically includes for request:
First data capture unit, for obtaining sessionstorage data as the first data;
Second data capture unit, for when next ajax asks to create the XmlHttpRequest stages, reading should The url and parameter of request, and as the second data;
Request judging unit is sent, for traversing each object in the first data, checking whether that there are url and parameter is The object data of second data abandons the request if it does, to repeat to submit;If it does not exist, then continuing to send request.
The effect provided in invention content is only the effect of embodiment, rather than invents all whole effects, above-mentioned A technical solution in technical solution has the following advantages that or advantageous effect:
Compared with prior art, the present invention is preserved by the url and parameter for asking ajax to sessionstorage, is led to The record time for comparing request to create and current time are crossed, the automatic cleaning of data is made requests on according to the storage time of setting, And same request has been searched whether in sessionstorage according to the url and parameter of request next time, to avoid request weight Recurrence is sent, and solving the double hit operation occurred when page interim card causes js to execute delay can cause to repeat to submit asking for request Topic can effectively avoid the page and frequently occur stuck situation, promotes user experience.
The present invention carries out data analysis realization by js, is not required to based entirely on the data of browser end local storage function Server-side returned data is waited for, request can be avoided to repeat to submit in the case where not influencing user experience.
Description of the drawings
Fig. 1 is a kind of method flow diagram for preventing ajax requests from repeating to submit provided in the embodiment of the present invention;
Fig. 2 is a kind of system framework figure for preventing ajax requests from repeating to submit provided in the embodiment of the present invention.
Specific implementation mode
In order to clearly illustrate the technical characterstic of this programme, below by specific implementation mode, and its attached drawing is combined, to this Invention is described in detail.Following disclosure provides many different embodiments or example is used for realizing the different knots of the present invention Structure.In order to simplify disclosure of the invention, hereinafter the component of specific examples and setting are described.In addition, the present invention can be with Repeat reference numerals and/or letter in different examples.This repetition is that for purposes of simplicity and clarity, itself is not indicated Relationship between various embodiments and/or setting is discussed.It should be noted that illustrated component is not necessarily to scale in the accompanying drawings It draws.Present invention omits the descriptions to known assemblies and treatment technology and process to avoid the present invention is unnecessarily limiting.
Be provided for the embodiments of the invention below in conjunction with the accompanying drawings it is a kind of prevent ajax request repeat submit method and be System is described in detail.
As shown in Figure 1, the embodiment of the invention discloses a kind of method for preventing ajax requests from repeating to submit, including following step Suddenly:
S101, url, parameter, record time and the current time for reading ajax requests to be sent, preserve extremely In sessionstorage.
Ajax ask create the XmlHttpRequest stages, read the request url and parameter as character string a, and Using time when creating XmlHttpRequest as the record time, it is denoted as character string b;
Current time is obtained, as character string c;
It is stored in sessionstorage using character string a, b, c as an object.Sessionstorage is deposited for local Store up the data in a session, only the page in the same session could access and data are also therewith after conversation end It destroys.All ajax are asked to store into sessionstorage in the form of array, the ajax to be sent is asked Url, parameter, record time and current time be stored in the array in sessionstorage in the form of object, facilitate pair Request is managed.
S102, cleaning is timed to storage data according to the time difference.
By be arranged timing function, at regular intervals the period just obtain sessionstorage data;
Due in sessionstorage data include ajax to be sent request the record time and current time, can To decide whether to clear up storage data according to the difference of record time and current time.
Traverse sessionstorage data in the record time and current time, upon recording between with current time when Between difference when being greater than the set value, delete the data in array;The size of time difference setting value can be set according to demand. By to the data dump before between certain, to which the real-time of data in sessionstorage be effectively ensured.
Modified array is newly stored into sessionstorage.
S103, next ajax requests are compared and are stored to the url in sessionstorage, parameter, tied according to comparing Whether decisive and resolute fixed request sends.
Sessionstorage data are obtained as data1, ask to create XmlHttpRequest ranks in next ajax Duan Shi reads the url and parameter of the request, and as data2;
Each object in data1 is traversed, checks whether that there are the object datas that url and parameter are data2;
If it is present there are identical ajax requests to send before indicating, to repeat to submit, therefore castout request; If it does not exist, then continuing to send request.
The embodiment of the present invention is preserved by the url and parameter for asking ajax to sessionstorage, is created by comparing Record time and the current time for building request, the automatic cleaning of data are made requests on according to the storage time of setting, and under The url and parameter of secondary request have searched whether same request in sessionstorage, to avoid request from repeating to send, solution It the problem of double hit operation occurred when page interim card causes js to execute delay of having determined can cause to repeat to submit request, can effectively keep away Exempt from the page and frequently occur stuck situation, promotes user experience.
It is real to carry out data analysis based entirely on the data of browser end local storage function by js for the embodiment of the present invention It is existing, server-side returned data is withouted waiting for, request can be avoided to repeat to submit in the case where not influencing user experience.
As shown in Fig. 2, the embodiment of the invention also discloses a kind of systems for preventing ajax requests from repeating to submit, including:
Url and parameter memory module, for read the url of ajax to be sent request, parameter, the record time and it is current when Between, it preserves into sessionstorage;Url, parameter, record time and the current time of the ajax to be sent request with Array in the form deposit sessionstorage of object.
The automatic cleaning modul of data is stored, for being timed cleaning to storage data according to storage time difference;It is described to deposit Store up the difference that the time difference is current time and record time.
The automatic cleaning modul of the storage data specifically includes:
Request data timing acquisition unit, for timing function to be arranged, at regular intervals the period just obtain Sessionstorage data;
Storage time difference acquiring unit traverses the record time of the every data of array in sessionstorage data and works as Preceding time, record storage time difference;
Request data deleting unit when being greater than the set value for difference between when stored, deletes this request data in array;
Again storage unit, for modified array to be newly stored into sessionstorage.
Judge request whether sending module, for comparing next ajax request and storing into sessionstorage Url, parameter determine whether request sends according to comparison result.
It is described to judge whether sending module specifically includes for request:
First data capture unit, for obtaining sessionstorage data as the first data;
Second data capture unit, for when next ajax asks to create the XmlHttpRequest stages, reading should The url and parameter of request, and as the second data;
Request judging unit is sent, for traversing each object in the first data, checking whether that there are url and parameter is The object data of second data abandons the request if it does, to repeat to submit;If it does not exist, then continuing to send request.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the invention, all essences in the present invention All any modification, equivalent and improvement etc., should all be included in the protection scope of the present invention made by within refreshing and principle.

Claims (10)

1. a kind of method for preventing ajax requests from repeating to submit, which is characterized in that include the following steps:
S101, url, parameter, record time and the current time for reading ajax requests to be sent, preserve extremely In sessionstorage;
S102, cleaning is timed to storage data according to storage time difference;
S103, next ajax requests are compared and are stored to the url in sessionstorage, parameter, determined according to comparison result Whether fixed request sends.
2. a kind of method for preventing ajax requests from repeating to submit according to claim 1, which is characterized in that described to be sent Url, parameter, record time and the current time of ajax requests are stored in the number in sessionstorage in the form of object Group.
3. a kind of method for preventing ajax requests from repeating to submit according to claim 1, which is characterized in that when the storage Between difference be current time with record the time difference.
4. a kind of method for preventing ajax requests from repeating to submit according to claim 1-3 any one, which is characterized in that The step S102 is specially:
Be arranged timing function, at regular intervals the period just obtain sessionstorage data;
Traverse record time and current time of the array per data, record storage time difference in sessionstorage data;
When difference is greater than the set value between when stored, this request data in array is deleted;
Modified array is newly stored into sessionstorage.
5. a kind of method for preventing ajax requests from repeating to submit according to claim 1-3 any one, which is characterized in that The step S103 is specially:
Sessionstorage data are obtained as data1;
When next ajax asks to create the XmlHttpRequest stages, the url and parameter of the request are read, and as data2;
Each object in data1 is traversed, checks whether that there are the object datas that url and parameter are data2;
If it does, to repeat to submit, the request is abandoned;If it does not exist, then continuing to send request.
6. a kind of system for preventing ajax requests from repeating to submit, which is characterized in that including:
Url and parameter memory module, url, parameter, record time and current time for reading ajax requests to be sent, It preserves into sessionstorage;
The automatic cleaning modul of data is stored, for being timed cleaning to storage data according to storage time difference;
Judge request whether sending module, for compare next ajax request and store in sessionstorage url, Parameter determines whether request sends according to comparison result.
7. a kind of system for preventing ajax requests from repeating to submit according to claim 6, which is characterized in that described to be sent Url, parameter, record time and the current time of ajax requests are stored in the number in sessionstorage in the form of object Group.
8. a kind of system for preventing ajax requests from repeating to submit according to claim 6, which is characterized in that when the storage Between difference be current time with record the time difference.
9. a kind of system for preventing ajax requests from repeating to submit according to claim 6-8 any one, which is characterized in that The automatic cleaning modul of the storage data specifically includes:
Request data timing acquisition unit, for timing function to be arranged, at regular intervals the period just obtain Sessionstorage data;
Storage time difference acquiring unit, traverse sessionstorage data in array per data the record time and it is current when Between, the record storage time difference;
Request data deleting unit when being greater than the set value for difference between when stored, deletes this request data in array;
Again storage unit, for modified array to be newly stored into sessionstorage.
10. a kind of system for preventing ajax requests from repeating to submit according to claim 6-8 any one, feature exist In described to judge whether sending module specifically includes for request:
First data capture unit, for obtaining sessionstorage data as the first data;
Second data capture unit, for when next ajax asks to create the XmlHttpRequest stages, reading the request Url and parameter, and as the second data;
Request judging unit is sent, for traversing each object in the first data, checks whether that there are url and parameter be second The object data of data abandons the request if it does, to repeat to submit;If it does not exist, then continuing to send request.
CN201810280363.3A 2018-04-02 2018-04-02 A kind of method and system for preventing ajax requests from repeating to submit Withdrawn CN108536793A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810280363.3A CN108536793A (en) 2018-04-02 2018-04-02 A kind of method and system for preventing ajax requests from repeating to submit

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810280363.3A CN108536793A (en) 2018-04-02 2018-04-02 A kind of method and system for preventing ajax requests from repeating to submit

Publications (1)

Publication Number Publication Date
CN108536793A true CN108536793A (en) 2018-09-14

Family

ID=63482145

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810280363.3A Withdrawn CN108536793A (en) 2018-04-02 2018-04-02 A kind of method and system for preventing ajax requests from repeating to submit

Country Status (1)

Country Link
CN (1) CN108536793A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110175310A (en) * 2019-06-03 2019-08-27 浪潮云信息技术有限公司 A kind of variation of foreground interface data showed slow solution
CN111078206A (en) * 2019-11-25 2020-04-28 贝壳技术有限公司 Form submitting method and system
CN114189559A (en) * 2021-12-14 2022-03-15 平安付科技服务有限公司 Interface repeat request processing method and system based on Axios
WO2023005326A1 (en) * 2021-07-26 2023-02-02 中兴通讯股份有限公司 Data processing method, and network element and computer-readable storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101394406A (en) * 2008-10-22 2009-03-25 深圳市金蝶中间件有限公司 Method and apparatus for preventing duplicate button pressing by user
CN106921645A (en) * 2016-06-28 2017-07-04 阿里巴巴集团控股有限公司 Information issuing method, client and service end
CN107147659A (en) * 2017-06-01 2017-09-08 上海斐讯数据通信技术有限公司 A kind of method and system for preventing to repeat

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101394406A (en) * 2008-10-22 2009-03-25 深圳市金蝶中间件有限公司 Method and apparatus for preventing duplicate button pressing by user
CN106921645A (en) * 2016-06-28 2017-07-04 阿里巴巴集团控股有限公司 Information issuing method, client and service end
CN107147659A (en) * 2017-06-01 2017-09-08 上海斐讯数据通信技术有限公司 A kind of method and system for preventing to repeat

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
李晓明: "《基于 JavaWeb技术的表单重复提交问题解决方案分析与应用》", 《电脑知识与技术》 *

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110175310A (en) * 2019-06-03 2019-08-27 浪潮云信息技术有限公司 A kind of variation of foreground interface data showed slow solution
CN111078206A (en) * 2019-11-25 2020-04-28 贝壳技术有限公司 Form submitting method and system
CN111078206B (en) * 2019-11-25 2023-03-24 贝壳技术有限公司 Form submitting method and system
WO2023005326A1 (en) * 2021-07-26 2023-02-02 中兴通讯股份有限公司 Data processing method, and network element and computer-readable storage medium
CN114189559A (en) * 2021-12-14 2022-03-15 平安付科技服务有限公司 Interface repeat request processing method and system based on Axios
CN114189559B (en) * 2021-12-14 2024-02-06 平安付科技服务有限公司 Axios-based interface repeated request processing method and system

Similar Documents

Publication Publication Date Title
CN108536793A (en) A kind of method and system for preventing ajax requests from repeating to submit
Meeder et al. We know who you followed last summer: inferring social link creation times in twitter
CN110020062B (en) Customizable web crawler method and system
CN103761279B (en) Method and system for scheduling network crawlers on basis of keyword search
US20190109920A1 (en) Browser resource pre-pulling method, terminal and storage medium
CN107256180B (en) Data processing method, device and terminal
CN106326025A (en) Method and device for processing abnormality of browser
CN109981715B (en) Session management method and device
CN109831429A (en) A kind of Webshell detection method and device
CN106790195B (en) A kind of SQL injection detection method and device
CN103699544B (en) The method and system of cross-page selection data
CN109729044A (en) A kind of general internet data acquisition is counter to climb system and method
CN104994139A (en) System capable of quickly responding to high-concurrency network request
CN107026871A (en) A kind of Web vulnerability scanning methods based on cloud computing
CN105718307B (en) Process management method and management of process device
CN114328132A (en) Method, device, equipment and medium for monitoring state of external data source
US20080155465A1 (en) Identifying items that have experienced recent interest bursts
US8234243B2 (en) Third tier transactional commit for asynchronous replication
CN114356581A (en) Memory cleaning method and related equipment
CN103595747A (en) User-information recommending method and system
CN106339176A (en) Intermediate file processing method, client, server and system
US9864771B2 (en) Method and server for synchronizing a plurality of clients accessing a database
US20140164270A1 (en) Method, system and computer readable medium for recommending medium users
CN109150819B (en) A kind of attack recognition method and its identifying system
US9973421B2 (en) Method and device for connection management in a telecommunication network

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WW01 Invention patent application withdrawn after publication

Application publication date: 20180914

WW01 Invention patent application withdrawn after publication