CN113076497A - Front-end and back-end asynchronous request calling method, device, equipment and medium - Google Patents

Front-end and back-end asynchronous request calling method, device, equipment and medium Download PDF

Info

Publication number
CN113076497A
CN113076497A CN202110419855.8A CN202110419855A CN113076497A CN 113076497 A CN113076497 A CN 113076497A CN 202110419855 A CN202110419855 A CN 202110419855A CN 113076497 A CN113076497 A CN 113076497A
Authority
CN
China
Prior art keywords
html
landing page
environment
domain name
ajax request
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.)
Pending
Application number
CN202110419855.8A
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.)
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Wodong Tianjun 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 Beijing Jingdong Century Trading Co Ltd, Beijing Wodong Tianjun Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN202110419855.8A priority Critical patent/CN113076497A/en
Publication of CN113076497A publication Critical patent/CN113076497A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • G06F16/986Document structures and storage, e.g. HTML extensions

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The embodiment of the invention provides a method, a device, equipment and a medium for calling a front-end asynchronous request and a back-end asynchronous request, wherein the method comprises the following steps: determining an access environment corresponding to the calling of the front-end and back-end asynchronous Ajax requests; loading a corresponding HTML (hypertext markup language) landing page according to the access environment, and analyzing a domain name corresponding to the Ajax request under the access environment from the HTML landing page; loading corresponding static resources in an HTML landing page, and splicing the domain name and the interface identification of the Ajax request under the corresponding access environment by using the static resources to obtain an interface under the corresponding access environment; the Ajax request is sent to the webpage application server corresponding to the access environment through the interface, so that the Ajax request is called, the efficiency of determining the correct domain name and interface is effectively improved, and the accuracy of the domain name and the interface when the Ajax request is called in different access environments is improved.

Description

Front-end and back-end asynchronous request calling method, device, equipment and medium
Technical Field
The embodiment of the invention relates to the technical field of webpage development, in particular to a method, a device, equipment and a medium for calling a front-end asynchronous request and a back-end asynchronous request.
Background
Asynchronous JavaScript And XML (english is called Asynchronous JavaScript And XML for short: Ajax) technology is a technology for creating better And faster Web applications with stronger interactivity. Ajax technology enables web applications to quickly present incremental updates on a user interface without having to reload an entire page, and is therefore widely used.
At present, when a front end calls a front-end asynchronous request (Ajax request for short) to acquire data of a server, domain names and interfaces of the called Ajax request are different in a pre-release environment and an online environment. There are two main schemes for implementing the specific invocation of Ajax requests. The first solution is to use a first domain name and interface in a pre-release environment. The method is realized by manually modifying the first domain name and the interface into the second domain name and the interface in an online environment. The second solution is to use the front end scaffold to configure different packaged commands of the scaffold in the pre-release environment and the on-line environment to modify the domain name and the interface.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art: since the domain name and the interface are required to be modified, the efficiency of determining the correct domain name and interface is low, and neglect is easy to occur in the modification process, so that the accuracy of the domain name and the interface is low when the Ajax request is called under different environments.
Disclosure of Invention
Embodiments of the present invention provide a method, an apparatus, a device, and a medium for calling a front-end and a back-end asynchronous request, which are used to solve the technical problems in the prior art that the efficiency of determining a correct domain name and an interface is low, and the domain name and the interface are low in accuracy when an Ajax request is called in different environments due to negligence in a modification process.
In a first aspect, an embodiment of the present invention provides a method for calling a front-end and back-end asynchronous request, including:
determining an access environment corresponding to the calling of the front-end and back-end asynchronous Ajax requests;
loading a corresponding HTML landing page according to the access environment, and analyzing a domain name corresponding to the Ajax request under the access environment from the HTML landing page;
loading corresponding static resources in the HTML landing page, and splicing the domain name and the interface identifier of the Ajax request under the corresponding access environment by using the static resources to obtain an interface under the corresponding access environment;
and sending the Ajax request to a webpage application server corresponding to the access environment through the interface so as to realize the invocation of the Ajax request.
In a second aspect, an embodiment of the present invention provides a front-end and back-end asynchronous request invoking device, including:
the determining module is used for determining an access environment corresponding to the calling of the front-end and back-end asynchronous Ajax requests;
the loading module is used for loading a corresponding hypertext markup language HTML landing page according to the access environment;
the analysis module is used for analyzing the domain name corresponding to the Ajax request under the access environment from the HTML landing page;
the loading module is also used for loading corresponding static resources in the HTML landing page;
the splicing module is used for splicing the domain name and the interface identifier of the Ajax request under the corresponding access environment by using the static resource so as to obtain an interface under the corresponding access environment;
and the sending module is used for sending the Ajax request to a webpage application server corresponding to the access environment through the interface so as to realize the calling of the Ajax request.
In a third aspect, an embodiment of the present invention provides an electronic device, including: at least one processor, a memory, and a transceiver;
the processor, the memory and the transceiver are interconnected through a circuit;
the memory stores computer-executable instructions; the transceiver is used for receiving and transmitting data with the webpage application server;
the at least one processor executing the computer-executable instructions stored by the memory causes the at least one processor to perform the method of any one of the first aspects.
In a fourth aspect, the present invention provides a computer-readable storage medium, in which computer-executable instructions are stored, and when executed by a processor, the computer-executable instructions are used to implement the method according to any one of the first aspect.
In a fifth aspect, an embodiment of the present invention provides a computer program product, which includes a computer program that, when executed by a processor, implements the method of any one of the first aspect.
According to the method, the device, the equipment and the medium for calling the front-end and back-end asynchronous requests, which are provided by the embodiment of the invention, the corresponding access environment when the front-end and back-end asynchronous Ajax requests are called is determined; loading a corresponding HTML (hypertext markup language) landing page according to the access environment, and analyzing a domain name corresponding to the Ajax request under the access environment from the HTML landing page; loading corresponding static resources in an HTML landing page, and splicing the domain name and the interface identification of the Ajax request under the corresponding access environment by using the static resources to obtain an interface under the corresponding access environment; the method comprises the steps of sending Ajax requests to a webpage application server corresponding to access environments through interfaces to achieve calling of the Ajax requests, directly writing domain names of the Ajax requests corresponding to each access environment into corresponding HTML landing pages as loading of corresponding HTML landing pages and static resources is a necessary link for calling the Ajax requests, splicing the domain names and interface identifications of the Ajax requests through the static resources to obtain corresponding interfaces, determining correct domain names and interfaces in a special modification mode is not needed, and efficiency of determining the correct domain names and interfaces is effectively improved. And the domain name under each access environment is written into the corresponding HTML landing page in advance, so that errors of the domain name and the interface caused by negligence or other reasons can be avoided, and the accuracy of the domain name and the interface when the Ajax request is called under different environments is improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
FIG. 1 is a diagram of a network architecture of a front-end and back-end asynchronous request call method in a pre-release environment, in which embodiments of the present invention may be implemented;
FIG. 2 is a diagram of a network architecture in an online environment for a front-end and back-end asynchronous request invocation method that may implement an embodiment of the present invention;
fig. 3 is a flowchart illustrating a front-end and back-end asynchronous request call method according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating a front-end and back-end asynchronous request call method according to another embodiment of the present invention;
FIG. 5 is a flowchart illustrating step 201 of a front-end and back-end asynchronous request call method according to another embodiment of the present invention;
FIG. 6 is a flowchart illustrating step 208 of the front-end and back-end asynchronous request call method according to another embodiment of the present invention;
FIG. 7 is a flowchart illustrating step 209 of the front-end and back-end asynchronous request call method according to another embodiment of the present invention;
FIG. 8 is a flowchart illustrating step 210 of a front-end and back-end asynchronous request call method according to another embodiment of the present invention;
FIG. 9 is a flowchart illustrating step 211 of the front-end and back-end asynchronous request call method according to another embodiment of the present invention;
FIG. 10 is a block diagram of a front-end and back-end asynchronous request call device according to an embodiment of the present invention;
FIG. 11 is a schematic structural diagram of an electronic device for implementing a front-end and back-end asynchronous request call method according to an embodiment of the present invention;
FIG. 12 is a block diagram of an electronic device used to implement a front-end asynchronous request call method of an embodiment of the present invention.
With the foregoing drawings in mind, certain embodiments of the disclosure have been shown and described in more detail below. These drawings and written description are not intended to limit the scope of the disclosed concepts in any way, but rather to illustrate the concepts of the disclosure to those skilled in the art by reference to specific embodiments.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
First, terms related to embodiments of the present invention are explained:
front-end and back-end asynchronous requests: for short: ajax request. The front end and the server end interact with each other through http, in the interaction process, the front end needs to send an Ajax request, and a Uniform Resource Locator (URL) needs to be determined when the Ajax request is sent, wherein the URL is also called an interface for sending the Ajax request.
Front end scaffold: the front-end scaffold can build a development environment for a front-end project, and can also pack the whole front-end project according to a certain rule.
Javascript: is a front-end web page development language, which is a lightweight, interpreted or just-in-time programming language with function precedence. Is a scripting language for developing Web pages.
It should be noted that the examples of the domain name test, the test interface, the online domain name and the online interface illustrated in the embodiment of the present invention are not real, and are only illustrated in the form of the domain name and the interface.
For a clear understanding of the technical solutions of the present application, a detailed description of the prior art solutions is first provided.
At present, when the front end calls the Ajax request to acquire the data of the server, the domain name and the interface of the called Ajax request are different under a pre-release environment and an online environment. The following illustrates the domain name and interface of the invoked Ajax request in the pre-release environment and the online environment: in the pre-release environment, when the Ajax request is called, the testing domain name of the Ajax request can be http:// beta-color.jd, and the testing interface URL can be http:// beta-color.jd/getUser. In an online environment, when the Ajax request is called, the online domain name of the Ajax request can be http:// color.jdl.id, and the online interface URL can be http:// color.jdl.id/getUser.
At present, there are two main schemes for calling Ajax requests. The first solution is to use a first domain name and interface in a pre-release environment. The method is realized by manually modifying the first domain name and the interface into the second domain name and the interface in an online environment. The second solution is to use the front end scaffold to configure different packaged commands of the scaffold in the pre-release environment and the on-line environment to modify the domain name and the interface.
Specifically, in the first scheme, when the pre-release environment is tested, the domain name of the Ajax request set in the front-end javascript code is "http:// beta-color. And then, splicing the interface identification by using the domain name to form a first interface, and further calling the Ajax request. After the test is finished, the Ajax request domain name and the interface set by the javascript code are manually modified in an online environment, the Ajax request domain name is changed into a second domain name which is http:// color.
In a second approach, the packaged commands of the scaffolding are configured using a front end scaffold. Before the javascript code is deployed, different packing commands are input, and the value of the ajax request domain name variable is changed. For example, in a pre-distribution environment, a packing command "npm run test" is input to change the value of an ajax request domain name variable in a javascript code, and finally the variable is assigned as "http:// beta-color.jd", and then when the front end sends an ajax request, the value of the variable is spliced to achieve the result that the interface is "http:// beta-color.jd/getUser". In an online environment, a packing command 'npm run built' is input to change the value of an ajax request domain name variable in a javascript code, the variable is finally assigned as 'http:// color.jd', and then the value of the variable is spliced when the current end sends an ajax request, so that the result that the interface is 'http:// color.jd/getUser' is achieved.
In the first scheme, the domain name and interface need to be modified manually, making it inefficient to determine the correct domain name and interface. In the second scheme, although the domain name and the interface do not need to be modified manually, in order to adapt to the pre-release environment and the online environment, two commands need to be switched back and forth for inputting, which makes it difficult to avoid that the domain name and the interface are low in accuracy when the Ajax request is called in different environments because a packaged command of the pre-release environment is input due to negligence or other reasons when the online environment is about to be deployed.
Therefore, in the face of the technical problems in the prior art, the inventor discovers through creative research that although the types of the current front-end development framework are many, after the final development is completed, the front-end development framework is generally packaged through webpack, and the main resource types formed after the packaging are consistent. For the Ajax call request link, HTML (hypertext markup language) landing pages (also called index. HTML) and static resources (also called js) are related to the Ajax call request link. After the requirement development is completed, the HTML landing page is mainly responsible for setting some page attributes and introducing static resources, and in subsequent requirement iterations, almost most of code changes are finally packaged into a new static resource file by webpack, but the HTML landing page is hardly changed. Therefore, the HTML landing pages of the pre-release environment and the on-line environment are distinguished by relying on the property that the HTML landing pages are rarely changed, the domain name of the Ajax request in the pre-release environment is written into the HTML landing pages in the pre-release environment, and the domain name of the Ajax request in the on-line environment is written into the HTML landing pages in the on-line environment. And the domain name and the interface identification corresponding to the Ajax request can be spliced by using the static resources in the corresponding access environment to obtain an interface in the corresponding access environment, and then the Ajax request is sent to the webpage application server in the corresponding access environment through the interface to realize the invocation of the Ajax request. The domain name of the Ajax request in each access environment is written into the HTML landing page in the corresponding access environment. Therefore, even if the access environments are different, the domain name and the interface of the Ajax request under the corresponding access environment can be obtained by loading the corresponding HTML landing page and the static resource, and the call of the Ajax request is further realized. Because the loading of the corresponding HTML landing page and the static resource is a necessary link for calling the Ajax request, the domain name of the corresponding Ajax request under each access environment is directly written into the corresponding HTML landing page, and the domain name and the interface identification of the Ajax request are spliced through the static resource to obtain the corresponding interface, so that the correct domain name and interface are determined without a special modification mode, and the efficiency of determining the correct domain name and interface is effectively improved. And the domain name under each access environment is written into the corresponding HTML landing page in advance, so that errors of the domain name and the interface caused by negligence or other reasons can be avoided, and the accuracy of the domain name and the interface when the Ajax request is called under different environments is improved.
Therefore, the inventor proposes a technical scheme of the embodiment of the invention based on the above creative discovery. The following describes a network architecture of the front-end and back-end asynchronous request calling method provided by the embodiment of the invention in different access environments.
Fig. 1 is a network architecture diagram of a front-end and back-end asynchronous request call method in a pre-distribution environment, which can implement an embodiment of the present invention, and as shown in fig. 1, the network architecture in the pre-distribution environment includes: the electronic device 1, the HTML landing page server 21 corresponding to the pre-release environment, the first HTML landing page code library 211, the static resource server 31 corresponding to the pre-release environment, the first static resource code library 311, and the web application server 41 corresponding to the pre-release environment. The first HTML landing page code library 211 is located in the HTML landing page server 21 corresponding to the pre-distribution environment, and is used for storing HTML landing pages in the pre-distribution environment. The HTML landing page in the pre-publishing environment is the first HTML landing page. The first static resource code base 311 is located in the static resource server 31 corresponding to the pre-release environment, and is used for storing the static resources in the pre-release environment. The static resource in the pre-release environment is a first static resource. The electronic device 1 is in communication connection with the HTML landing page server 21 corresponding to the pre-release environment, the static resource server 31 corresponding to the pre-release environment, and the web application server 41 corresponding to the pre-release environment, respectively. Then, in the pre-distribution environment, when the electronic device 1 serves as the front end to send the Ajax request to the web application server 41 corresponding to the pre-distribution environment, the electronic device 1 loads the first HTML landing page from the first HTML landing page code library 211 of the HTML landing page server 21 corresponding to the pre-distribution environment. And analyzing the domain name of the Ajax request under the pre-release environment from the first HTML landing page. If the domain name requested by the Ajax under the pre-release environment is: "http:// beta-color.jdl.id". And loads the first static resource from the first static resource code library 311 of the static resource server 31 corresponding to the pre-release environment, and loads the first static resource into the HTML landing page. And splicing the domain name and the interface identification of the Ajax request in the pre-release environment by using the static resource to obtain the interface in the pre-release environment. Further, the electronic device 1 sends the Ajax request to the web application server 41 in the pre-release environment through the interface, so as to call the Ajax request.
Fig. 2 is a network architecture diagram of a front-end and back-end asynchronous request invoking method in an online environment, where the network architecture in the online environment includes: the electronic device 1, the HTML landing page server 22 corresponding to the online environment, the second HTML landing page code library 221, the static resource server 32 corresponding to the online environment, the second static resource code library 321, and the web application server 42 corresponding to the online environment. The second HTML landing page code library 221 is located in the HTML landing page server 22 corresponding to the online environment, and is used for storing the HTML landing pages in the online environment. The HTML landing page in the online environment is the second HTML landing page. The second static resource code base 321 is located in the static resource server 32 corresponding to the online environment, and is used for storing the static resources in the online environment. The static resource in the online environment is a second static resource. The electronic device 1 is in communication connection with the HTML landing page server 22 corresponding to the online environment, the static resource server 32 corresponding to the online environment, and the web application server 42 corresponding to the online environment, respectively. When the electronic device 1 sends the Ajax request to the web application server 42 corresponding to the online environment as a front end in the online environment, the electronic device 1 loads the second HTML landing page from the second HTML landing page code base 221 of the HTML landing page server 22 corresponding to the online environment. And analyzing the domain name corresponding to the Ajax request under the access environment from the second HTML landing page. For example, the domain name requested by Ajax in the online environment is: "http:// color.jdl.id". And loads the second static resource from the second static resource code base 321 of the static resource server 32 corresponding to the online environment, and loads the second static resource into the HTML landing page. And splicing the domain name and the interface identification of the Ajax request in the online environment by using static resources to obtain an interface in the online environment. Further, the electronic device 1 sends the Ajax request to the web application server 42 of the online environment through the interface, so as to implement the call of the Ajax request.
The following describes the technical solution of the present invention and how to solve the above technical problems with specific examples. The following several specific embodiments may be combined with each other, and details of the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present invention will be described below with reference to the accompanying drawings.
Example one
Fig. 3 is a schematic flowchart of a method for calling a front-end and back-end asynchronous request according to an embodiment of the present invention, and as shown in fig. 3, an execution main body of the method for calling a front-end and back-end asynchronous request provided in this embodiment is a front-end and back-end asynchronous request calling device, where the front-end and back-end asynchronous request calling device is located in an electronic device, and the electronic device is a front-end device. The method for calling the front-end and back-end asynchronous requests provided by the embodiment comprises the following steps:
step 101, determining an access environment corresponding to calling of front-end and back-end asynchronous Ajax requests.
The access environment may be a pre-release environment or an online environment, which is not limited in this embodiment.
In this embodiment, in the pre-distribution environment and the online environment, the electronic device is different as a server accessed by the front end. Under the pre-release environment, the server accessed by the electronic equipment is a pre-release environment web page application server. In an online environment, the server accessed by the electronic device is an online environment web application server. When the electronic device accesses the pre-release environment web application server, the host of the pre-release environment web application server needs to be configured, and the host of the pre-release environment web application server is bound with the domain name requested by the Ajax. When the electronic equipment accesses the online environment webpage application server, the host of the online environment webpage application server does not need to be bound with the domain name requested by Ajax. The electronic device may determine an access environment corresponding to invoking the Ajax request by determining whether the host of the web application server is bound to the domain name of the Ajax request.
The host works according to the TCP/IP for Windows standard, and contains the mapping relation between the IP address and the host name of the pre-release environment webpage application server.
And 102, loading a corresponding HTML landing page according to the access environment, and analyzing a domain name corresponding to the Ajax request in the access environment from the HTML landing page.
The hypertext markup language is abbreviated as HTML. The HTML landing page is simply referred to as an HTML landing page.
In this embodiment, the landing pages of different access environments are stored in different servers in advance, and the domain name of the Ajax request corresponding to each access environment is written in the HTML landing page of each access environment in advance. After the access environment is determined, the HTML landing page is loaded from the HTML landing page server corresponding to the access environment, and the HTML landing page is analyzed to obtain the domain name corresponding to the Ajax request in the access environment.
For example, in a pre-release environment, the domain name of the Ajax request pre-written in the corresponding HTML landing page may be "http:// beta-color.jdl.d". In an online environment, the domain name of the Ajax request pre-written in the corresponding HTML landing page may be http:// color.
When the domain name of the Ajax request corresponding to the access environment is written in the HTML landing page of each access environment in advance, the domain name variable of the Ajax request can be defined first, and then the domain name variable of the Ajax request is written in a mode of assigning values. Or written in other ways, which is not limited in this embodiment.
And 103, loading corresponding static resources in the HTML landing page, and splicing the domain name and the interface identifier of the Ajax request under the corresponding access environment by using the static resources to obtain an interface under the corresponding access environment.
In this embodiment, when the Ajax request is invoked, not only the HTML landing page needs to be loaded, but also the corresponding static resource needs to be introduced into the HTML landing page. In each access environment, the static resources are respectively stored in the corresponding servers, so that the static resources are obtained from the corresponding servers according to the access environment, and then the static resources are loaded into the corresponding HTML landing pages. In particular, static resources may be loaded to the bottom of the HTML landing page.
In this embodiment, in each access environment, the static resource may include an interface identifier of an interface corresponding to the Ajax request. And the HTML landing page also comprises the domain name of the Ajax request corresponding to the access environment, so that the domain name and the interface identification of the Ajax request corresponding to the access environment can be spliced by using static resources to form an interface corresponding to the access environment.
Continuing with step 102 for illustrative purposes: under the pre-publishing environment, the domain name of the Ajax request pre-written in the corresponding HTML landing page can be http:// beta-color.jdl.id, the interface identifier is getUser, and then the interface of the Ajax request under the pre-publishing environment after splicing is as follows: "http:// beta-color.jdl/getUser". In an online environment, the domain name of the Ajax request written in advance in the corresponding HTML landing page can be http:// color.jdl.id, the interface identifier is getUser, and then the interface of the Ajax request in the online environment after splicing is as follows: "http:// color.jdl.id/getUser".
And 104, sending the Ajax request to a webpage application server corresponding to the access environment through an interface so as to realize the invocation of the Ajax request.
In this embodiment, after the interface in the corresponding access environment is determined, the web application server in the corresponding access environment is accessed through the interface, that is, the Ajax request is sent to the web application server in the corresponding access environment through the interface, and then data is obtained from the web application server in the corresponding access environment and fed back to the electronic device.
In the method for calling the front-end and back-end asynchronous requests, the access environment corresponding to the calling of the front-end and back-end asynchronous Ajax requests is determined; loading a corresponding HTML (hypertext markup language) landing page according to the access environment, and analyzing a domain name corresponding to the Ajax request under the access environment from the HTML landing page; loading corresponding static resources in an HTML landing page, and splicing the domain name and the interface identification of the Ajax request under the corresponding access environment by using the static resources to obtain an interface under the corresponding access environment; the method comprises the steps of sending Ajax requests to a webpage application server corresponding to access environments through interfaces to achieve calling of the Ajax requests, directly writing domain names of the Ajax requests corresponding to each access environment into corresponding HTML landing pages as loading of corresponding HTML landing pages and static resources is a necessary link for calling the Ajax requests, splicing the domain names and interface identifications of the Ajax requests through the static resources to obtain corresponding interfaces, determining correct domain names and interfaces in a special modification mode is not needed, and efficiency of determining the correct domain names and interfaces is effectively improved. And the domain name under each access environment is written into the corresponding HTML landing page in advance, so that errors of the domain name and the interface caused by negligence or other reasons can be avoided, and the accuracy of the domain name and the interface when the Ajax request is called under different environments is improved.
Example two
Fig. 4 is a schematic flowchart of a front-end and back-end asynchronous request invoking method according to another embodiment of the present invention, and as shown in fig. 4, the front-end and back-end asynchronous request invoking method according to this embodiment further refines steps 102 to 103 on the basis of the front-end and back-end asynchronous request invoking method according to the first embodiment, and further includes a step of writing corresponding domain names of Ajax requests to HTML landing pages corresponding to different access environments, storing and deploying the HTML landing pages, and a step of storing and deploying static resources of different access environments. The method for calling the front-end and back-end asynchronous requests provided by the embodiment comprises the following steps:
step 201, a first HTML landing page corresponding to the pre-publishing environment and a second HTML landing page corresponding to the online environment are determined.
As an alternative implementation, as shown in fig. 5, in this embodiment, step 201 includes the following steps:
in step 2011, a default HTML landing page is obtained.
In this embodiment, after the web application is developed according to the requirement, the HTML landing page is rarely changed even if the requirement is continuously iterated, so that the HTML landing page after the web application is developed can be obtained as the preset HTML landing page.
The developed Javascript codes can be packaged and acquired by the HTML landing page after the webpage application is developed through the webpack.
Step 2012, defining a domain name variable of the Ajax request at a first preset position in the preset HTML landing page.
And 2013, assigning the domain name variable of the Ajax request to the domain name of the Ajax request corresponding to the pre-release environment so as to determine the first HTML landing page.
Step 2014, assigning the domain name variable of the Ajax request to the domain name of the Ajax request corresponding to the online environment to determine a second HTML landing page.
In this embodiment, a first preset position is determined in a preset HTML landing page, and a domain name variable of the Ajax request is defined at the first preset position. The domain name requested by Ajax is different under different access environments. Therefore, the Ajax request domain name variable in the preset HTML landing page in different access environments can be assigned to different values to form the HTML landing page in different access environments.
Specifically, in this embodiment, if the variable of the domain name of the Ajax request is "requestDomain", for example, assigning the variable of the domain name of the Ajax request to the domain name of the Ajax request corresponding to the pre-release environment may be represented as: "requestDomain ═ http:// beta-color.jd'". Assigning the domain name variable of the Ajax request to the domain name of the Ajax request corresponding to the online environment can be expressed as: "requestDomain ═ http:// color.
And after the domain name variable of the Ajax request is assigned to the domain name of the Ajax request corresponding to the pre-release environment, determining the preset HTML landing page as a first HTML landing page. And after the domain name variable of the Ajax request is assigned to the domain name of the Ajax request corresponding to the online environment, determining the preset HTML landing page as a second HTML landing page.
Step 202, storing the first HTML landing page into a first HTML landing page code base corresponding to the pre-distribution environment, and storing the second HTML landing page into a second HTML landing page code base corresponding to the online environment.
In this embodiment, the domain names of the Ajax requests written in the first HTML landing page and the second HTML landing page are different, and represent the domain names of the Ajax requests in different access environments. Therefore, in order to quickly and accurately acquire the domain name corresponding to the Ajax request in the access environment, the first HTML landing page and the second HTML landing page are stored separately. Specifically, the first HTML landing page is stored in an HTML landing page code base corresponding to the pre-publishing environment, and the second HTML landing page is stored in an HTML landing page code base corresponding to the online environment.
And the first HTML landing page code base is an HTML landing page code base corresponding to the pre-release environment. And the second HTML landing page code base is an HTML landing page code base corresponding to the online environment.
And 203, deploying the first HTML landing page code library to an HTML landing page server corresponding to the pre-release environment, and deploying the second HTML landing page code library to an HTML landing page server corresponding to the online environment.
In this embodiment, the first HTML landing page code library is deployed in the HTML landing page server corresponding to the pre-distribution environment, and the second HTML landing page code library is deployed in the HTML landing page server corresponding to the online environment, so that the first HTML landing page code library and the second HTML landing page code library can be isolated more effectively.
Step 204, determining a first static resource corresponding to the pre-release environment and a second static resource corresponding to the online environment.
The static resource corresponding to the pre-release environment is a first static resource, and the static resource corresponding to the online environment is a second static resource.
In this embodiment, after the webpage application is pre-published, the webpack packages the pre-published Javascript code to obtain the first static resource. Similarly, after the web page application is on line, the web page application packages the Javascript code of the on line by the webpack, and a second static resource can be obtained.
Step 205, storing the first static resource into a first static resource code base corresponding to the pre-release environment, and storing the second static resource into a second static resource code base corresponding to the online environment.
And step 206, deploying the first static resource code base to a static resource server corresponding to the pre-release environment, and deploying the second static resource code base to a static resource server corresponding to the online environment.
In this embodiment, in order to distinguish static resources of different access environments, the first static resource is stored in a static resource code base corresponding to the pre-release environment, and the first static resource code base is deployed in a static resource server corresponding to the pre-release environment. And storing the second static resource in a static resource code base corresponding to the online environment, and deploying the second static resource code base in a static resource server corresponding to the online environment.
And the first static resource code base is a static resource code base corresponding to the pre-release environment. And the second static resource code base is a static resource code base corresponding to the online environment.
Step 207, determining the corresponding access environment when the Ajax request is called.
In this embodiment, the implementation manner of step 207 is similar to that of step 101 in the first embodiment, and is not described in detail here.
And step 208, loading the corresponding HTML landing page according to the access environment.
As an alternative implementation, as shown in fig. 6, in this embodiment, step 208 includes the following steps:
step 2081, determining an HTML landing page server for deploying a corresponding HTML landing page code base according to the access environment.
Step 2082, loading the HTML landing page corresponding to the access environment from the HTML landing page code base in the HTML landing page server.
In this embodiment, since the HTML landing pages in different access environments are stored in the HTML landing page code library of the corresponding HTML landing page server, the HTML landing page server in the corresponding access environment is accessed to obtain the corresponding HTML landing page from the corresponding code library.
When accessing the HTML landing page server in the pre-distribution environment, the IP address and the host name of the HTML landing page server in the pre-distribution environment need to be determined according to the host of the HTML landing page server in the pre-distribution environment, so as to complete the access to the HTML landing page server in the pre-distribution environment.
Step 209, the domain name corresponding to the Ajax request in the access environment is analyzed from the HTML landing page.
As an alternative implementation, as shown in fig. 7, in this embodiment, step 209 includes the following steps:
step 2091, obtain a first preset location of a domain name variable defining the Ajax request in the HTML landing page.
Step 2092, resolving the domain name corresponding to the Ajax request in the access environment according to the first preset position.
In this embodiment, since the domain name variable of the Ajax request is defined at the first preset position when being defined into the corresponding HTML landing page, the first preset position where the domain name variable of the Ajax request is defined in the HTML landing page can be obtained, the HTML landing page is analyzed from the first preset position, and the domain name of the Ajax request in the corresponding access environment is further obtained.
And step 210, loading corresponding static resources in the HTML landing page.
As an alternative implementation, as shown in fig. 8, in this embodiment, step 210 includes the following steps:
step 2101, determining a static resource server to deploy a corresponding static resource code base according to the access environment.
Step 2102, obtain a corresponding static resource from a static resource code base in a static resource server.
In this embodiment, because the static resources in different access environments are respectively stored in the static resource code libraries of the corresponding static resource servers, the static resource servers in the corresponding access environments are accessed to obtain the corresponding static resources from the corresponding code libraries.
When accessing the static resource server in the pre-release environment, the IP address and the host name of the static resource server in the pre-release environment need to be determined according to the host of the static resource server in the pre-release environment, so as to complete the access to the static resource server in the pre-release environment.
And 2103, loading the static resource into the corresponding HTML landing page.
Specifically, in this embodiment, after the static resource is obtained, the static resource is loaded to the bottom of the HTML landing page in the corresponding access environment, so that the HTML landing page introduces the corresponding static resource, and the preparation for invoking the Ajax request in the corresponding access environment is implemented.
And step 211, splicing the domain name and the interface identifier of the Ajax request under the corresponding access environment by using the static resource to obtain an interface under the corresponding access environment.
As an alternative implementation, as shown in fig. 9, in this embodiment, step 211 includes the following steps:
step 2111, obtaining the domain name of Ajax request in HTML landing page under corresponding access environment by using static resource.
In this embodiment, since the static resource is loaded into the HTML landing page in the corresponding access environment, the domain name requested by the Ajax can be obtained from the first preset location.
Step 2112, the interface identifier stored in the second preset location is obtained from the static resource.
In this embodiment, the interface identifier is stored in the static resource, and may be specifically stored in the second preset location, so that the interface identifier may be obtained from the second preset location.
It should be noted that the interface identifiers when the Ajax request is called in the pre-release environment and the online environment may be the same.
Step 2113, splicing the domain name and the interface identifier of the Ajax request by adopting a preset separator to obtain an interface under the corresponding access environment.
In this embodiment, the preset delimiter may be "/", or may also be another preset delimiter agreed between the front end and the web application server, which is not limited in this embodiment.
And step 212, sending the Ajax request to a webpage application server corresponding to the access environment through an interface so as to realize the invocation of the Ajax request.
In this embodiment, the implementation manner of step 212 is similar to that of step 104 in the first embodiment, and is not described in detail here.
In the front-end and back-end asynchronous request calling method provided by this embodiment, when a first HTML landing page corresponding to a pre-distribution environment and a second HTML landing page corresponding to an online environment are determined, a preset HTML landing page is obtained; defining a domain name variable of the Ajax request at a first preset position in a preset HTML landing page; assigning a domain name variable of the Ajax request to a domain name of the Ajax request corresponding to a pre-release environment so as to determine a first HTML landing page; and assigning the domain name variable of the Ajax request to the domain name of the Ajax request corresponding to the online environment so as to determine a second HTML landing page, and quickly and accurately writing the domain name of the Ajax request into the HTML landing page corresponding to the access environment by assigning the variable.
The front-end and back-end asynchronous request calling method provided by this embodiment determines a first HTML landing page corresponding to a pre-distribution environment and a second HTML landing page corresponding to an online environment; storing the first HTML landing page into a first HTML landing page code base corresponding to a pre-release environment, and storing the second HTML landing page into a second HTML landing page code base corresponding to an online environment; and deploying the first HTML landing page code library to an HTML landing page server corresponding to the pre-release environment, and deploying the second HTML landing page code library to an HTML landing page server corresponding to the online environment. The first HTML landing page code library and the second HTML landing page code library can be more effectively isolated. And loading corresponding HTML landing pages under different access environments to prepare for distinguishing Ajax request domain names under different access environments.
According to the front-end and back-end asynchronous request calling method provided by the embodiment, when the static resource is used for splicing the domain name and the interface identifier of the Ajax request in the corresponding access environment to obtain the interface in the corresponding access environment, the static resource is used for obtaining the domain name of the Ajax request in the HTML (hypertext markup language) landing page in the corresponding access environment; acquiring an interface identifier stored in a second preset position from the static resource; and splicing the domain name of the Ajax request and the interface identifier by adopting a preset separator to obtain an interface under a corresponding access environment, so that when the static resource obtains the domain name of the corresponding Ajax request, the static resource directly obtains the domain name from the corresponding HTML landing page without distinguishing the domain name of the Ajax request according to the access environment, and the splicing efficiency of the interface under the corresponding access environment is improved.
EXAMPLE III
Fig. 10 is a schematic structural diagram of a front-end and back-end asynchronous request call device according to an embodiment of the present invention, and as shown in fig. 10, a front-end and back-end asynchronous request call device 30 according to the embodiment includes: the system comprises a determining module 31, a loading module 32, a resolving module 33, a splicing module 34 and a sending module 35.
The determining module 31 is configured to determine an access environment corresponding to calling the front-end and back-end asynchronous Ajax requests. And the loading module 32 is used for loading the corresponding HTML landing page according to the access environment. And the analyzing module 33 is configured to analyze the domain name corresponding to the Ajax request in the access environment from the HTML landing page. And the loading module 32 is further configured to load the corresponding static resource in the HTML landing page. And the splicing module 34 is configured to splice the domain name and the interface identifier of the Ajax request in the corresponding access environment by using the static resource to obtain an interface in the corresponding access environment. And the sending module 35 is configured to send the Ajax request to the web application server corresponding to the access environment through the interface, so as to implement invocation of the Ajax request.
Optionally, the access environment comprises: pre-release environment and online environment. Correspondingly, the front-end and back-end asynchronous request calling device 30 provided in this embodiment further includes: a storage module and a deployment module.
The determining module 31 is further configured to determine a first HTML landing page corresponding to the pre-distribution environment and a second HTML landing page corresponding to the online environment. And the storage module is used for storing the first HTML landing page into a first HTML landing page code base corresponding to the pre-release environment and storing the second HTML landing page into a second HTML landing page code base corresponding to the online environment. And the deployment module is used for deploying the first HTML landing page code library into an HTML landing page server corresponding to the pre-release environment and deploying the second HTML landing page code library into an HTML landing page server corresponding to the online environment.
Optionally, the determining module 31, when determining the first HTML landing page corresponding to the pre-distribution environment and the second HTML landing page corresponding to the online environment, is specifically configured to:
acquiring a preset HTML landing page; defining a domain name variable of the Ajax request at a first preset position in a preset HTML landing page; assigning a domain name variable of the Ajax request to a domain name of the Ajax request corresponding to a pre-release environment so as to determine a first HTML landing page; and assigning the domain name variable of the Ajax request to the domain name of the Ajax request corresponding to the online environment so as to determine a second HTML landing page.
Optionally, the loading module 32, when loading the corresponding HTML landing page according to the access environment, is specifically configured to:
determining an HTML landing page server for deploying a corresponding HTML landing page code library according to the access environment; and loading the HTML landing page corresponding to the access environment from an HTML landing page code library in the HTML landing page server.
Optionally, the parsing module 33 is specifically configured to: acquiring a first preset position of a domain name variable defining an Ajax request in an HTML (hypertext markup language) landing page; and resolving the domain name corresponding to the Ajax request under the access environment according to the first preset position.
Optionally, the determining module 31 is further configured to determine a first static resource corresponding to the pre-release environment and a second static resource corresponding to the online environment. The storage module is further configured to store the first static resource in a first static resource code base corresponding to the pre-release environment, and store the second static resource in a second static resource code base corresponding to the online environment. The deployment module is further configured to deploy the first static resource code base to a static resource server corresponding to the pre-release environment, and deploy the second static resource code base to a static resource server corresponding to the online environment.
Optionally, the loading module 32 is specifically configured to determine, according to the access environment, a static resource server that deploys a corresponding static resource code base when loading the corresponding static resource in the HTML landing page; acquiring corresponding static resources from a static resource code library in a static resource server; and loading the static resources into the corresponding HTML landing page.
Optionally, the splicing module 34 is specifically configured to:
acquiring a domain name of an Ajax request in an HTML (hypertext markup language) landing page in a corresponding access environment by using a static resource; acquiring an interface identifier stored in a second preset position from the static resource; and splicing the domain name and the interface identification of the Ajax request by adopting a preset separator to obtain an interface under the corresponding access environment.
The front-end and back-end asynchronous request calling device provided in this embodiment may execute the technical solution of the method embodiment shown in fig. 3 to 9, and the implementation principle and technical effect thereof are similar to those of the method embodiment shown in fig. 3 to 9, and are not described in detail here.
Example four
Fig. 11 is a schematic structural diagram of an electronic device for implementing a front-end and back-end asynchronous request call method according to an embodiment of the present invention, and as shown in fig. 11, an electronic device 40 provided in this embodiment includes: a memory 41, a processor 42 and a transceiver 43.
The processor 42, the memory 41 and the transceiver 43 are electrically interconnected;
the memory 41 stores computer-executable instructions; a transceiver 43 for transceiving data with the web application server;
the at least one processor 42 executes the computer-executable instructions stored by the memory to cause the at least one processor to perform the method of either embodiment one or embodiment two.
EXAMPLE five
Fig. 12 is a block diagram of an electronic device for implementing the front-end and back-end asynchronous request call method according to an embodiment of the present invention, and as shown in fig. 12, the electronic device 500 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, an exercise device, a personal digital assistant, or the like.
Among other things, the electronic device 500 may include one or more of the following components: processing component 502, memory 504, power component 506, multimedia component 508, audio component 510, input/output (I/O) interface 512, sensor component 514, and communication component 516.
The processing component 502 generally controls overall operation of the device 500, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing components 502 may include one or more processors 520 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 502 can include one or more modules that facilitate interaction between the processing component 502 and other components. For example, the processing component 502 can include a multimedia module to facilitate interaction between the multimedia component 508 and the processing component 502.
The memory 504 is configured to store various types of data to support operations at the apparatus 500. Examples of such data include instructions for any application or method operating on device 500, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 504 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The power supply component 506 provides power to the various components of the device 500. The power components 506 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the apparatus 500.
The multimedia component 508 includes a screen that provides an output interface between the device 500 and the user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 508 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the device 500 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 510 is configured to output and/or input audio signals. For example, audio component 510 includes a Microphone (MIC) configured to receive external audio signals when apparatus 500 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 504 or transmitted via the communication component 516. In some embodiments, audio component 510 further includes a speaker for outputting audio signals.
The I/O interface 512 provides an interface between the processing component 502 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button.
The sensor assembly 514 includes one or more sensors for providing various aspects of status assessment for the device 500. For example, the sensor assembly 514 may detect an open/closed state of the apparatus 500, the relative positioning of the components, such as a display and keypad of the apparatus 500, the sensor assembly 514 may also detect a change in position of the apparatus 500 or a component of the apparatus 500, the presence or absence of user contact with the apparatus 500, orientation or acceleration/deceleration of the apparatus 500, and a change in temperature of the apparatus 500. The sensor assembly 514 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 514 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 514 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 516 is configured to facilitate communication between the apparatus 500 and other devices in a wired or wireless manner. The apparatus 500 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 516 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 516 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 500 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 504 comprising instructions, executable by the processor 520 of the apparatus 500 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
A non-transitory computer readable storage medium having instructions therein, which when executed by a processor of an electronic device, enable the electronic device to perform a front-end asynchronous request call method as provided in embodiment one or embodiment two.
In an exemplary embodiment, a computer program product is further provided, which includes a computer program, and the computer program is executed by a processor to execute the front-end and back-end asynchronous request calling method provided in the first embodiment or the second embodiment.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (17)

1. A front-end and back-end asynchronous request calling method is characterized by comprising the following steps:
determining an access environment corresponding to the calling of the front-end and back-end asynchronous Ajax requests;
loading a corresponding HTML landing page according to the access environment, and analyzing a domain name corresponding to the Ajax request under the access environment from the HTML landing page;
loading corresponding static resources in the HTML landing page, and splicing the domain name and the interface identifier of the Ajax request under the corresponding access environment by using the static resources to obtain an interface under the corresponding access environment;
and sending the Ajax request to a webpage application server corresponding to the access environment through the interface so as to realize the invocation of the Ajax request.
2. The method of claim 1, wherein the access context comprises: pre-release environment and online environment;
before loading the corresponding HTML landing page according to the access environment, the method further comprises the following steps:
determining a first HTML landing page corresponding to a pre-release environment and a second HTML landing page corresponding to an online environment;
storing the first HTML landing page into a first HTML landing page code base corresponding to a pre-release environment, and storing the second HTML landing page into a second HTML landing page code base corresponding to an online environment;
and deploying the first HTML landing page code library to an HTML landing page server corresponding to the pre-release environment, and deploying the second HTML landing page code library to an HTML landing page server corresponding to the online environment.
3. The method of claim 2, wherein determining a first HTML landing page for a pre-release environment and a second HTML landing page for an online environment comprises:
acquiring a preset HTML landing page;
defining a domain name variable of the Ajax request at a first preset position in the preset HTML landing page;
assigning the domain name variable of the Ajax request to a domain name of the Ajax request corresponding to a pre-release environment so as to determine the first HTML landing page;
and assigning the domain name variable of the Ajax request to the domain name of the Ajax request corresponding to the online environment so as to determine the second HTML landing page.
4. The method of claim 2, wherein loading the corresponding HTML landing page according to the access environment comprises:
determining an HTML landing page server for deploying a corresponding HTML landing page code library according to the access environment;
and loading the HTML landing page corresponding to the access environment from an HTML landing page code library in the HTML landing page server.
5. The method of claim 3, wherein the parsing the domain name corresponding to the Ajax request in the access environment from the HTML landing page comprises:
acquiring a first preset position of a domain name variable defining the Ajax request in the HTML landing page;
and resolving the domain name corresponding to the Ajax request under the access environment according to the first preset position.
6. The method of claim 1, wherein before loading the corresponding static resource in the HTML landing page, further comprising:
determining a first static resource corresponding to a pre-release environment and a second static resource corresponding to an online environment;
storing the first static resource into a first static resource code base corresponding to a pre-release environment, and storing the second static resource into a second static resource code base corresponding to an online environment;
and deploying the first static resource code base to a static resource server corresponding to the pre-release environment, and deploying the second static resource code base to a static resource server corresponding to the online environment.
7. The method of claim 6, wherein loading the corresponding static resource in the HTML landing page comprises:
determining a static resource server for deploying a corresponding static resource code library according to the access environment;
acquiring corresponding static resources from a static resource code library in the static resource server;
and loading the static resource into a corresponding HTML landing page.
8. The method according to any one of claims 1 to 7, wherein the splicing the domain name and the interface identifier of the Ajax request in the corresponding access environment by using the static resource to obtain the interface in the corresponding access environment comprises:
acquiring a domain name of an Ajax request in an HTML (hypertext markup language) landing page in a corresponding access environment by using a static resource;
acquiring an interface identifier stored in a second preset position from the static resource;
and splicing the domain name of the Ajax request and the interface identification by adopting a preset separator to obtain an interface under a corresponding access environment.
9. A front-end and back-end asynchronous request invocation apparatus, comprising:
the determining module is used for determining an access environment corresponding to the calling of the front-end and back-end asynchronous Ajax requests;
the loading module is used for loading a corresponding hypertext markup language HTML landing page according to the access environment;
the analysis module is used for analyzing the domain name corresponding to the Ajax request under the access environment from the HTML landing page;
the loading module is also used for loading corresponding static resources in the HTML landing page;
the splicing module is used for splicing the domain name and the interface identifier of the Ajax request under the corresponding access environment by using the static resource so as to obtain an interface under the corresponding access environment;
and the sending module is used for sending the Ajax request to a webpage application server corresponding to the access environment through the interface so as to realize the calling of the Ajax request.
10. The apparatus of claim 9, wherein the access environment comprises: pre-release environment and online environment; the device, still include: a storage module and a deployment module;
the determining module is further used for determining a first HTML landing page corresponding to the pre-distribution environment and a second HTML landing page corresponding to the online environment;
the storage module is used for storing the first HTML landing page into a first HTML landing page code base corresponding to the pre-release environment and storing the second HTML landing page into a second HTML landing page code base corresponding to the online environment;
and the deployment module is used for deploying the first HTML landing page code library into an HTML landing page server corresponding to the pre-release environment and deploying the second HTML landing page code library into an HTML landing page server corresponding to the online environment.
11. The apparatus of claim 10, wherein the determining module, when determining the first HTML landing page corresponding to the pre-distribution environment and the second HTML landing page corresponding to the online environment, is specifically configured to:
acquiring a preset HTML landing page; defining a domain name variable of the Ajax request at a first preset position in the preset HTML landing page;
assigning the domain name variable of the Ajax request to a domain name of the Ajax request corresponding to a pre-release environment so as to determine the first HTML landing page;
and assigning the domain name variable of the Ajax request to the domain name of the Ajax request corresponding to the online environment so as to determine the second HTML landing page.
12. The apparatus of claim 10, wherein the loading module, when loading the corresponding HTML landing page according to the access environment, is specifically configured to:
determining an HTML landing page server for deploying a corresponding HTML landing page code library according to the access environment; and loading the HTML landing page corresponding to the access environment from an HTML landing page code library in the HTML landing page server.
13. The apparatus of claim 11, wherein the parsing module is specifically configured to:
acquiring a first preset position of a domain name variable defining the Ajax request in the HTML landing page;
and resolving the domain name corresponding to the Ajax request under the access environment according to the first preset position.
14. The apparatus according to any one of claims 9 to 13, wherein the splicing module is specifically configured to:
acquiring a domain name of an Ajax request in an HTML (hypertext markup language) landing page in a corresponding access environment by using a static resource;
acquiring an interface identifier stored in a second preset position from the static resource;
and splicing the domain name of the Ajax request and the interface identification by adopting a preset separator to obtain an interface under a corresponding access environment.
15. An electronic device, comprising: at least one processor, a memory, and a transceiver;
the processor, the memory and the transceiver are interconnected through a circuit;
the memory stores computer-executable instructions; the transceiver is used for receiving and transmitting data with the webpage application server;
the at least one processor executing the computer-executable instructions stored by the memory causes the at least one processor to perform the method of any one of claims 1-8.
16. A computer-readable storage medium having computer-executable instructions stored thereon, which when executed by a processor, perform the method of any one of claims 1-8.
17. A computer program product comprising a computer program, characterized in that the computer program realizes the method of any of claims 1-8 when executed by a processor.
CN202110419855.8A 2021-04-19 2021-04-19 Front-end and back-end asynchronous request calling method, device, equipment and medium Pending CN113076497A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110419855.8A CN113076497A (en) 2021-04-19 2021-04-19 Front-end and back-end asynchronous request calling method, device, equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110419855.8A CN113076497A (en) 2021-04-19 2021-04-19 Front-end and back-end asynchronous request calling method, device, equipment and medium

Publications (1)

Publication Number Publication Date
CN113076497A true CN113076497A (en) 2021-07-06

Family

ID=76618244

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110419855.8A Pending CN113076497A (en) 2021-04-19 2021-04-19 Front-end and back-end asynchronous request calling method, device, equipment and medium

Country Status (1)

Country Link
CN (1) CN113076497A (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100037150A1 (en) * 2008-08-05 2010-02-11 Accenture Global Services Gmbh Synchronous to Asynchronous Web Page Conversion
US8307003B1 (en) * 2009-03-31 2012-11-06 Amazon Technologies, Inc. Self-service control environment
CN107402880A (en) * 2016-05-20 2017-11-28 腾讯科技(北京)有限公司 A kind of method of testing and electronic equipment
CN110149423A (en) * 2019-07-04 2019-08-20 深圳市珍爱捷云信息技术有限公司 Domain name processing method, device, readable storage medium storing program for executing and electronic equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100037150A1 (en) * 2008-08-05 2010-02-11 Accenture Global Services Gmbh Synchronous to Asynchronous Web Page Conversion
US8307003B1 (en) * 2009-03-31 2012-11-06 Amazon Technologies, Inc. Self-service control environment
CN107402880A (en) * 2016-05-20 2017-11-28 腾讯科技(北京)有限公司 A kind of method of testing and electronic equipment
CN110149423A (en) * 2019-07-04 2019-08-20 深圳市珍爱捷云信息技术有限公司 Domain name processing method, device, readable storage medium storing program for executing and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
常艳;: "Ajax跨域访问问题的分析与解决", 电子技术与软件工程, no. 10, 15 May 2020 (2020-05-15) *

Similar Documents

Publication Publication Date Title
CN111273899B (en) Code processing method, device, electronic equipment and storage medium
EP3848798A1 (en) Information processing method and apparatus, storage medium, and electronic device
CN107423218A (en) Application testing method, device and terminal
CN110781080A (en) Program debugging method and device and storage medium
CN115185717A (en) Interface calling method and device, electronic equipment and storage medium
CN109684112B (en) Program file operation method, device, terminal and storage medium
CN114741292A (en) Test script management method and device, electronic equipment and storage medium
CN110851370B (en) Program testing method and device and storage medium
EP4024208B1 (en) Method for launching quick application, and related device
CN111221613B (en) Program calling method and device and storage medium
CN104991857A (en) Method and apparatus for trace debugging
CN109976872B (en) Data processing method and device, electronic equipment and storage medium
CN110221813B (en) Application data connection establishment method and device, storage medium and electronic equipment
CN115373763B (en) Plug-in loading method and device, electronic equipment and storage medium
CN111079040A (en) Resource sniffing method, device, terminal, server and storage medium
CN113626321B (en) Bridging test method, device, system and storage medium
CN110989987A (en) Portal webpage generation method, portal webpage generation device, client, server and storage medium
CN116361242A (en) File acquisition method and device, electronic equipment and readable storage medium
CN111338961B (en) Application debugging method and device, electronic equipment and storage medium
CN105630948A (en) Web page display method and apparatus
CN113076497A (en) Front-end and back-end asynchronous request calling method, device, equipment and medium
CN112631695B (en) Data verification method and device, electronic equipment and storage medium
CN111124553B (en) Program execution method, device, terminal and storage medium
CN110647351B (en) Source code map file restoration method, device and storage medium
CN116450534B (en) Method, device, equipment and medium for generating mobile terminal application program

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