[go: up one dir, main page]

CN105991739B - A kind of data request method and device - Google Patents

A kind of data request method and device Download PDF

Info

Publication number
CN105991739B
CN105991739B CN201510091917.1A CN201510091917A CN105991739B CN 105991739 B CN105991739 B CN 105991739B CN 201510091917 A CN201510091917 A CN 201510091917A CN 105991739 B CN105991739 B CN 105991739B
Authority
CN
China
Prior art keywords
request
target data
function
data
agent side
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.)
Active
Application number
CN201510091917.1A
Other languages
Chinese (zh)
Other versions
CN105991739A (en
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.)
Advanced New Technologies Co Ltd
Advantageous New Technologies Co Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201510091917.1A priority Critical patent/CN105991739B/en
Publication of CN105991739A publication Critical patent/CN105991739A/en
Application granted granted Critical
Publication of CN105991739B publication Critical patent/CN105991739B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/02Protocols based on web technology, e.g. hypertext transfer protocol [HTTP]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)
  • Computer And Data Communications (AREA)

Abstract

The present invention provides a kind of data request method and device, and wherein method includes: to generate request mark and respectively request end corresponding with the request mark and agent side;Target data required for the request end is requested to server by the agent side;The request identifies corresponding agent side and obtains the target data that the server returns, and identifies corresponding request end by the request and use the target data performance objective business.The data receiver of present invention realization high accuracy.

Description

A kind of data request method and device
Technical field
The present invention relates to network technology, in particular to a kind of data request method and device.
Background technique
Web data request is data required for requesting display web page as user end to server, in the related technology may be used To server request data in a manner of using JSONP.For multiple request of data in same web page, JSONP can be defined Multiple call back function names of multiple request are respectively corresponded, and function name is transferred to server, which is used by server Function name returns to the data of request, so that client can be easy to distinguish the number of responses of corresponding different requests according to function name According to.But this mode needs the returned content different according to different functions name dynamic generation, server for server Processing pressure is larger.And if how setting server with unified form returned data, for client, accurately identifies The problem of difference requests corresponding response data, is urgent need to resolve.
Summary of the invention
In view of this, the present invention provides a kind of data request method and device, on the basis of mitigating server stress Improve the received accuracy of client data.
Specifically, the present invention is achieved through the following technical solutions:
In a first aspect, providing a kind of data request method, comprising:
Generate request mark and respectively request end corresponding with the request mark and agent side;
Target data required for the request end is requested to server by the agent side;
The request identifies corresponding agent side and obtains the target data that the server returns, and is identified by the request Corresponding request end uses the target data performance objective business.
Second aspect provides a kind of request of data device, comprising:
Identifier generation module, for generating request mark;
Function creation module, for creating request end corresponding with the request mark and agent side respectively;
The agent side for requesting target data required for the request end to server, and obtains the service The target data that device returns;
The request end uses the target data performance objective industry for identifying corresponding request end by the request Business.
The data request method and device of the embodiment of the present invention, by according to corresponding with the request end of event and agent side Request mark, making to call request identifies the target data of identical request end Receiving Agent end feedback, and this mode can be accurate Which event request is the data for determining that server returns be, client can be realized the data receiver of high accuracy.
Detailed description of the invention
Fig. 1 is the application scenario diagram of data request method in an example;
Fig. 2 is the flow chart of data request method in an example;
Fig. 3 is the frame principle of data request method in an example;
Fig. 4 is the multiple affair request schematic diagram of data request method in an example;
Fig. 5 is the structural schematic diagram of request of data device in an example.
Specific embodiment
The data request method of the embodiment of the present application can be applied to WEB request, such as scene shown in FIG. 1, WEB visitor Family end 11 is to 12 request data of WEB server.Wherein, WEB client side 11 can be at terminal (for example, PC, mobile terminal etc.) Some webpage run on browser, browser need to request to WEB server 12 normally when parsing executes the web page code Some data required for webpage are run, the data request method of the application can be used, at this time to obtain these data.
Fig. 2 illustrates the process of the data request method of client executing, as shown in Fig. 2, may include:
201, request mark and respectively request end corresponding with the request mark and agent side are generated;
202, target data required for the request end is requested to server by the agent side;
203, request identifies corresponding agent side and obtains the target data that the server returns, and is identified by the request Corresponding request end uses the target data performance objective business.
In order to enable this method process is easier to understand, referring initially to the example of Fig. 3, Fig. 3 illustrates the embodiment of the present application Data request method overall framework.One WEB page is when operating normally, wherein might have multiple display portion needs It is just able to achieve the normal display page to server request data, can be indicated with " event A " wherein once to server number of request According to event A is being got after the data that server is requested, and the data will be used to execute data processing stream as defined in event A Journey, to show the corresponding page in the part;Another time can be indicated with " event B " to server request data, equally will use Data execute process flow as defined in event B.It is, of course, also possible to which the same WEB page can wrap there are event C, event D etc. The event repeatedly to server request data is included, the present embodiment respectively indicates number different in WEB page with different " event " According to request, only it is exemplary in Fig. 3 for two kinds of events of display.Also, event A and event B use the present embodiment Data request method obtains data to server.
By taking event A therein as an example, event A is briefly described, data are obtained by server and handle the process of data, tying Fig. 3 is closed to describe to be involved in following several concepts when the process:
Agent side: it for example, the agent side can be a hiding empty IFRAME (frame), hides and is seen in the page Less than the IFRAME, sky is that any request or processing is not carried out in the IFRAME itself, and it is fixed only to execute webpage design personnel Logic inside the IFRAME of justice.In the present embodiment, it when using IFRAME as agent side, is equivalent in a WEB page In be provided with a nested page, that is, IFRAME, but the IFRAME is an independent running environment, is exclusively used in as to clothes Business device request page data (are equivalent to the middle-agent of request data in WEB page, rather than go server to ask by page itself Seek data).
" agent side " is arranged in WEB page in the present embodiment, mainly considers all to be usually in conventional manner by WEB page Itself is to server request data, and for the corresponding multiple events of multiple request of data in the page, WEB page will be responsible for differentiation The corresponding relationship of response data and request event that server returns, such as the page can create multiple functions (different function Name, respectively corresponds different event), that is, the event for needing to do page entirety is distinguished, very cumbersome;And after using " agent side ", such as Described in upper, it is the dedicated agent side of some event, for requesting the correspondence that each agent side, which is an independent running environment, The data of event, even if each agent side all uses identical function (for example being all define ()), the agent side of the page overall situation Between will not generate conflict, and the present embodiment only need by agent side respectively with each secondary event binding, for example, by using ID It distinguishes, subsequent embodiment will describe.
Request end: request end is in WEB page for request data and using the module of the data, such as the institute in Fig. 3 " second function " shown is properly termed as request end, and the explanation of the function may refer to following.
First function: shown in Figure 3, first function can be " overall situation function of IFRAME ", and agent side is to service Device request data, server can return to an executable script to agent side, include the event of agent side request in the script Data, agent side can execute the data that the script gets server return by first function.Also, the first function is also The data that can be will acquire are transferred to request end, such as the second function being transmitted in Fig. 3.It can be seen that the first function is For getting server returned data.
Second function: the second function can be " overall situation function of WEB page ", be used primarily for agent side acquisition The data arrived, and the corresponding call back function of event is called, the process flow as defined in call back function to data is executed, with this reality Business processing as defined in existing event, the corresponding page of display event.
Call back function: the call back function is mainly used for the data for defining how to get using agent side, that is, uses data The processing done;And above-mentioned second function is to call the call back function, executes processing as defined in the call back function, to complete Use to data.
Pass through Fig. 3 and above-mentioned conceptual description, it will be appreciated that event obtain data treatment process, i.e., from agent side to Server request data simultaneously receives data, then calls call back function by second function, and execute the process flow of call back function, Complete use of the event to data.
On the basis of above-mentioned Fig. 3 framework, the process of Fig. 2 is described as follows:
Process shown in Fig. 2 is WEB page when every secondary request data, the process that will be executed, still As shown in connection with fig. 3, when WEB page will execute the corresponding request of data of event A, then start to execute Fig. 2 process;Work as WEB page When executing the corresponding request of data of event B, also start to execute Fig. 2 process.In the concrete realization, the process of Fig. 2 actually phase When the method how done when some event of WEB page will be to server request data then defined, such as can be This method, can be known as JSONL, and this method is placed on the library for calling by designer's good method prepared in advance In;When event wants request data, then this method is called, and some parameters required for this method are transmitted to this method In, the process that Fig. 2 is executed according to these parameters is completed the acquisition of data by this method.
For example, it is assumed that data resource is stored in the server, the storage address URL of the data resource are as follows: http: // The resource content of www.alipay.com/info, address storage can be with are as follows:
define(
" name ": " Alipay "
“createDate”:“2004”
" description ": " Alipay network technology Co., Ltd "
“website”:“http://www.alipay.com”
“phone”:“0571-11110000”
)
And assumes that some event of WEB page will obtain the data, can be set in WEB page in webpage design personnel The resource of meter such as under type access address above mentioned:
{ value is JSONL (" http://www.alipay.com/info ", " define ", function (value)) Content in resource }
I.e. designer can with by the above-mentioned means, call directly the method JSONL in library, and by parameter " http: // Www.alipay.com/info ", " define ", function (value) are transferred to this method, are executed shown in Fig. 2 as this method Request of data process.Wherein, " http://www.alipay.com/info " is the address of data storage, and " define " is The function name for the executable script that server returns, and the first function in Fig. 3 also uses the function name;And function It (value) is call back function, it is specified that how to use data resource.
In step 201, client can be generated request mark and respectively at the request identify corresponding request end and Agent side, i.e. request end identify the request as the information for being used for the unique identification request end, and agent side also marks the request Know as the information for being used for the unique identification agent side.
For example, a dynamic I D generator can be set in JSONL method, WEB page is being received to JSONL method When calling, show to execute a data request event, then a random ID is created by dynamic I D generator, such as when difference Between generate different random numbers as random ID, which requests mark.
Request to create end and agent side are also wanted in this step, for example creation one hiding empty IFRAME and one is entirely Office's function will also establish the corresponding relationship of above-mentioned the request mark and the request end and agent side generated at random.For example, creation is asked End second function window [function name]=function (value) is asked, the function name of the second function is exactly above-mentioned random ID;An IFRAME is created,<iframe id=randomID></iframe>, i.e. the mark of the IFRAME is also request mark.
The client is by taking the WEB page of Fig. 3 as an example, when in the page including the event of multiple request of data, respectively often Corresponding request mark is arranged in one request of data, for example, the corresponding request mark of event A is " 11 ", the corresponding request of event B Mark is " 22 ".The second function of event A is window [11].
As described above, JSONL method is when creating second function, window [function name]=function (value), The parameter function (value) of client transmissions is used, i.e. second function calls call back function to execute the processing to data. And configured transmission " http://www.alipay.com/info " and " define ", it is the use in IFRAME creation, In the creation of IFRAME, the above-mentioned request generated at random is set by the ID of IFRAME and is identified, and is dynamically created in IFRAME SCRIPT label is built, URL incoming in advance is directed toward in address, initiates request of data to the URL.
For example, being created in IFRAME<script src=http://www.alipay.com/info></script>, Which includes above-mentioned URL.In addition, also creating first function in iframe, function name is define.
After the foundation for completing above-mentioned iframe and respective function, in step 202, by what is generated in execution 201 Logic, agent side is to server request target data, such as perform script < scriptsrc=http: // Www.alipay.com/info></script>, IFRAME just to server send request of data, request http: // The target data of the address www.alipay.com/info.
In step 203, server returns to target data to agent side IFRAME, and the form of return is, for example, define (target data), this is an executable script.The script is executed by the first function of IFRAME again and obtains target data, and Target data is transmitted to the second function of request end.Second function calls call back function to handle the target data, i.e., Use target data performance objective business.
As described above, in WEB page include multiple request data event when, each event will call execution Fig. 2 Process, such as call JSONL method, parameter is transmitted to the JSONL, by this method according to be passed to parameter execute Fig. 2 institute The process shown.When executing Fig. 2 process, each event can generate different request ID, and ID is as request end and generation for the request Manage the mark at end.
It should be noted that request end and agent side are established by corresponding relationship by " request identifies " in the present embodiment, it can To bring many effects, for example, shown in Figure 4, the event A and event B of WEB page all to server request data simultaneously, The present embodiment does not limit whether request data is identical, but WEB page, when receiving the data of server return, it is accurate to need Distinguishing the data returned is event A or event B.As shown in figure 4, being that event A is independent in the scheme of the present embodiment Agent side IFRAME is created, the target data of request event A needs, and the request end of event A and the IFRAME are exclusively used in Mark be all " 11 ";Agent side IFRAME is individually created for event B, is exclusively used in the target data of request event B needs, and And the request end of event B and the mark of the IFRAME are all " 22 ", then can by the request identify establish request end and The binding relationship of agent side, the data that IFRAME-22 is got can only be transmitted to request end --- and 22, without being transmitted to request End -11, because mark is not identical.
It can be seen which event request is the data that this mode can accurately determine that server returns be, client can Realize the data receiver of high accuracy.And for server, due to distinguishing the work of returned data and request end corresponding relationship Make accurately to realize via client itself, server can use unified data to return to form, such as Fig. 4 example , it is returned with the form of define (), that is, identical function name, in this way relative to the server side in traditional approach according to not With request using different return function names (distinguishing the data of different requests according to different functions name in order to facilitate client) come It says, server side saves resource consumption and development cost, accelerates response speed, and realize the static storage of data resource Etc. many benefits.
In addition, can be same numeric field data for the target data of agent side request, being also possible to cross-domain data.It is requesting It identifies corresponding request end and identifies corresponding agency using the request after target data performance objective business, can also be deleted End.For example, the corresponding IFRAME -11 of event A can be deleted after event A has used target data.I.e. client is at certain It when a event request data, is identified for the request of its dynamic generation, and creates the request and identify corresponding agent side IFRAME request Data can delete the IFRAME after obtaining data, and request mark can also delete, and next time can generate again and distribute to it His request of data.
In order to realize above-mentioned data request method, the embodiment of the present application also provides a kind of request of data device, the dresses It sets and can be applied to client.As shown in figure 5, the apparatus may include: identifier generation module 51, function creation module 52;Its In, identifier generation module 51, for generating request mark;Function creation module 52 is identified with the request respectively for creating Corresponding request end 53 and agent side 54.
Agent side 54 for requesting target data required for the request end to server, and obtains the server The target data of return;Request end 53 executes mesh using the target data for identifying corresponding request end by the request Mark business.
Further, identifier generation module 51 are specifically used for generating the request at random by dynamic marks generating mode Mark.
Further, function creation module 52, specifically for creating the overall situation function as request end, the overall situation function Function entitled request mark, the overall situation function is used to use target data performance objective business;Creation is as agent side Frame, the frame are hiding empty frames framves, and the request that is identified as that the frame is arranged identifies, and the frame is used for By script tag to server request target data.
Further, the frame, specifically for executing the call back function that the server returns by internal overall situation function, Obtain the target data that the server is returned by the call back function;And by the internal overall situation function by the target Data are transmitted to the overall situation function as request end.
Further, request end 53 are also used to after using the target data performance objective business, ask described in deletion Seek the corresponding agent side of mark.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the invention, all in essence of the invention Within mind and principle, any modification, equivalent substitution, improvement and etc. done be should be included within the scope of the present invention.

Claims (8)

1. a kind of data request method characterized by comprising
Generate request mark and respectively request end corresponding with the request mark and agent side;
Target data required for the request end is requested to server by the agent side;
The request identifies corresponding agent side and obtains the target data that the server returns, and is identified and corresponded to by the request Request end use the target data performance objective business;
It is described to generate request end corresponding with the request mark and agent side respectively, comprising:
Create the overall situation function as request end, the entitled request mark of the function of the overall situation function, the overall situation function For using the target data performance objective business;
The frame as agent side is created, the frame is hiding empty frames frame, and it is described that being identified as the frame is arranged Request mark, the frame are used to pass through script tag to server request target data.
2. the method according to claim 1, wherein generation request mark, comprising: raw by dynamic marks At mode, the request mark is generated at random.
3. the method according to claim 1, wherein the request, which identifies corresponding agent side, obtains the service The target data that device returns, and corresponding request end is identified by the request and uses the target data performance objective business, packet It includes:
The frame executes the call back function that the server returns by internal overall situation function, obtains the server and passes through institute State the target data of call back function return;
The target data is transmitted to the overall situation function as request end by the internal overall situation function by the frame, by institute The overall situation function for stating request end uses the target data performance objective business.
4. the method according to claim 1, wherein identifying corresponding request end in the request uses the mesh After mark data performance objective business, further includes:
It deletes the request and identifies the corresponding agent side.
5. a kind of request of data device characterized by comprising
Identifier generation module, for generating request mark;
Function creation module, for creating request end corresponding with the request mark and agent side respectively;
The agent side for requesting target data required for the request end to server, and obtains the server and returns The target data returned;
The request end uses the target data performance objective business for identifying corresponding request end by the request;
The function creation module, specifically for creating the overall situation function as request end, the function of the overall situation function is entitled The request mark, the overall situation function are used to use the target data performance objective business;Create the frame as agent side Frame, the frame are hiding empty frames framves, and the request that is identified as that the frame is arranged identifies, and the frame is for leading to Script tag is crossed to server request target data.
6. device according to claim 5, which is characterized in that the identifier generation module is specifically used for marking by dynamic Know generating mode, generates the request mark at random.
7. device according to claim 5, which is characterized in that
The frame obtains the clothes specifically for executing the call back function that the server returns by internal overall situation function The target data that business device is returned by the call back function;And the target data is transmitted to by the internal overall situation function Overall situation function as request end.
8. device according to claim 5, which is characterized in that
The request end is also used to after using the target data performance objective business, is deleted the request mark and is corresponded to The agent side.
CN201510091917.1A 2015-02-28 2015-02-28 A kind of data request method and device Active CN105991739B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510091917.1A CN105991739B (en) 2015-02-28 2015-02-28 A kind of data request method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510091917.1A CN105991739B (en) 2015-02-28 2015-02-28 A kind of data request method and device

Publications (2)

Publication Number Publication Date
CN105991739A CN105991739A (en) 2016-10-05
CN105991739B true CN105991739B (en) 2019-06-18

Family

ID=57038790

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510091917.1A Active CN105991739B (en) 2015-02-28 2015-02-28 A kind of data request method and device

Country Status (1)

Country Link
CN (1) CN105991739B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2008039117A1 (en) * 2006-09-29 2008-04-03 Telefonaktiebolget Lm Ericsson (Publ) A method and apparatus for controlling a proxy server
CN101686245A (en) * 2008-09-28 2010-03-31 国际商业机器公司 Method and system for isolating hypertext transfer protocol session

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100299588A1 (en) * 2009-05-21 2010-11-25 Michael Joseph Dattilo Method and system for providing interaction between a host system and web pages
US20130167156A1 (en) * 2011-12-21 2013-06-27 Microsoft Corporation Web page to toolbar communication

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2008039117A1 (en) * 2006-09-29 2008-04-03 Telefonaktiebolget Lm Ericsson (Publ) A method and apparatus for controlling a proxy server
CN101686245A (en) * 2008-09-28 2010-03-31 国际商业机器公司 Method and system for isolating hypertext transfer protocol session

Also Published As

Publication number Publication date
CN105991739A (en) 2016-10-05

Similar Documents

Publication Publication Date Title
EP2962216B1 (en) Sharing application states
CN110275831B (en) Mock data verification method and device of protocol interface
US10630671B2 (en) Dynamic web services server
CN108132814A (en) Page loading method, device, computer equipment and the storage medium of application program
CN103997452A (en) Information sharing method and apparatus among multiple platforms
US10171593B2 (en) Validating web services for compatibility with a client device by emulating the client device by populating a template associated with the web services
CN104268082B (en) The method for testing pressure and device of browser
CN110928767A (en) Webpage analysis method, device, equipment and storage medium
CN107463453B (en) Method, device, equipment and storage medium for communication between different applications of same terminal
KR20140119240A (en) Apparatus and method for processing an open api
US20170177727A1 (en) Methods for analyzing web sites using web services and devices thereof
US11252147B2 (en) Secure web application delivery platform
CN113568970B (en) Application business data management method, device, equipment and storage medium
CN111639275A (en) Routing information processing method and device, electronic equipment and computer storage medium
CN108881228A (en) Cloud registration activation method, device, equipment and storage medium
CN109783357A (en) The method and device of test application program, computer equipment, storage medium
CN111865881A (en) Interface conversion method, device, medium and computer equipment
CN110365724A (en) Task processing method, device and electronic equipment
CN107305528B (en) Application testing method and device
CN105871911A (en) Service calling engine, method and system
WO2021093672A1 (en) Method for embedding external system, workflow system, device and computer readable storage medium
CN104461893B (en) Data processing method and data processing equipment
CN104932910A (en) Method and system for application program interface extension
CN105991739B (en) A kind of data request method and device
CN108011936A (en) Method and apparatus for pushed information

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20200923

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Innovative advanced technology Co.,Ltd.

Address before: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee before: Advanced innovation technology Co.,Ltd.

Effective date of registration: 20200923

Address after: Cayman Enterprise Centre, 27 Hospital Road, George Town, Grand Cayman Islands

Patentee after: Advanced innovation technology Co.,Ltd.

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Patentee before: Alibaba Group Holding Ltd.