CN103150334A - Method and system for requesting picture file - Google Patents

Method and system for requesting picture file Download PDF

Info

Publication number
CN103150334A
CN103150334A CN 201310036033 CN201310036033A CN103150334A CN 103150334 A CN103150334 A CN 103150334A CN 201310036033 CN201310036033 CN 201310036033 CN 201310036033 A CN201310036033 A CN 201310036033A CN 103150334 A CN103150334 A CN 103150334A
Authority
CN
China
Prior art keywords
picture file
request
raw data
ajax
page
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
CN 201310036033
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.)
Shenzhen Coship Electronics Co Ltd
Original Assignee
Shenzhen Coship Electronics 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 Shenzhen Coship Electronics Co Ltd filed Critical Shenzhen Coship Electronics Co Ltd
Priority to CN 201310036033 priority Critical patent/CN103150334A/en
Publication of CN103150334A publication Critical patent/CN103150334A/en
Pending legal-status Critical Current

Links

Images

Abstract

The embodiment of the invention discloses a method for requesting a picture file, comprising the steps of obtaining a picture file request transmitted from a page through AJAX (Asynchronous JavaScript and XML), obtaining corresponding picture file original data according to the picture file request, decoding the picture file original data to obtain the picture file and displaying the picture file. The embodiment of the invention also discloses a system for requesting the picture file. With the adoption of the method and the system disclosed by the invention, the picture file can be asynchronously downloaded through AJAX and displayed, so that picture files in the page can be updated in real time on the premise that the whole page is not updated.

Description

A kind of method and system of asking picture file
Technical field
The present invention relates to internet arena, relate in particular to a kind of method and system of asking picture file.
Background technology
AJAX(Asynchronous JavaScript and XML, asynchronous JavaScript and XML) be a kind of webpage development technology for creating the interaction network page application.The core of AJAX is JavaScript object XmlHttpRequest, by this object can be directly and server communicate, can be in the situation that not load page and Web server swap data, AJAX uses asynchronous data transfer (Http request) between browser and Web server, make AJAX not load in whole webpage situation, can certain partial content of webpage be upgraded.All support AJAX synchronously and asynchronous download at all main flow browsers at present, as the response of need acquisition from server, can use object responseText or the responseXML attribute of AJAX.
In prior art, the Web page is by the AJAX request msg, only have responseText or responseXML by the data type that server returns, but responseText and responseXML are text formattings, if the page is wanted Asynchronous Request one pictures, can only go to download by browser, can't pass through the asynchronous download pictures of AJAX.
Summary of the invention
Embodiment of the present invention technical matters to be solved is, a kind of method and system of asking picture file are provided, and can and show by the asynchronous download pictures file of AJAX.
In order to solve the problems of the technologies described above, the embodiment of the present invention provides a kind of method of asking picture file, comprising:
Obtain the picture file request that the page sends by AJAX;
The picture file raw data corresponding according to described picture file acquisition request;
Described picture file raw data is decoded obtain picture file, and show described picture file.
Wherein, described picture file request comprises: the user is in the data of the page by the Asynchronous Request picture file of the object XmlHttpRequest submission of AJAX.
Wherein, the described picture file raw data corresponding according to described picture file acquisition request comprises:
Send described picture file HTTP request bag according to described picture file request to server, described picture file HTTP request comprises the access path of requested picture file;
Obtain the described picture file raw data that server returns according to described HTTP request bag.
Wherein, described picture file raw data is decoded obtains picture file, and show that described picture file comprises:
Obtain the positional information of described picture file in target pages according to described target pages, show described picture file according to the described positional information that gets.
Wherein, the described page that obtains comprises by the picture file request that AJAX sends before:
Obtain the object XmlHttpRequest of the described AJAX of page creation.
Correspondingly, the embodiment of the present invention also provides a kind of system that asks picture file, comprising:
Picture file acquisition request module is used for obtaining the picture file request that the page sends by AJAX;
Picture file raw data acquisition module is used for the picture file raw data corresponding according to described picture file acquisition request;
The picture file processing module, being used for decodes to described picture file raw data obtains picture file, and shows described picture file.
Wherein, described picture file request comprises: the user is in the data of the page by the Asynchronous Request picture file of the object XmlHttpRequest submission of AJAX.
Wherein, described picture file raw data acquisition module comprises:
Transmitting element is used for sending described picture file HTTP request bag according to described picture file request to server, and described picture file HTTP request comprises the access path of requested picture file;
Picture file raw data acquiring unit is used for obtaining the described picture file raw data that server returns according to described HTTP request bag.
Wherein, described picture file processing module comprises:
Display unit is used for obtaining described picture file in the positional information of target pages according to described target pages, shows described picture file according to the described positional information that gets.
Wherein, described system also comprises:
AJAX object acquisition module is for the object XmlHttpRequest of the described AJAX that obtains page creation.
Implement the embodiment of the present invention, have following beneficial effect: the page can be asked picture file by AJAX, browser can get the picture file raw data of the correspondence that server returns, can also show in the optional position of target pages this picture file, realized by the asynchronous download pictures file of AJAX and shown, under the prerequisite of not upgrading full page, but the picture file in the real-time update page.
Description of drawings
In order to be illustrated more clearly in the embodiment of the present invention or technical scheme of the prior art, the below will do to introduce simply to the accompanying drawing of required use in embodiment or description of the Prior Art, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skills, under the prerequisite of not paying creative work, can also obtain according to these accompanying drawings other accompanying drawing.
Fig. 1 is a kind of structural representation of asking the system of picture file in the embodiment of the present invention;
Fig. 2 is a kind of process flow diagram of asking the method for picture file in the embodiment of the present invention.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, rather than whole embodiment.Based on the embodiment in the present invention, those of ordinary skills belong to the scope of protection of the invention not making the every other embodiment that obtains under the creative work prerequisite.
Fig. 1 is a kind of structural representation of asking the system of picture file in the embodiment of the present invention, the present invention is a kind of asks the system of picture file can realize in the web browser client, the present embodiment a kind of system of picture file that asks can comprise picture file acquisition request module 110, picture file raw data acquisition module 120 and picture file processing module 130 at least as shown in the figure, wherein:
Picture file acquisition request module 110 is used for obtaining the picture file request that the page sends by AJAX.In specific implementation, the picture file request comprises: the user is in the data of the page by the Asynchronous Request picture file of the object XmlHttpRequest submission of AJAX.Wherein, the core of AJAX is JavaScript object XmlHttpRequest, AJAX is at web browser and Web(network) use asynchronous data transfer (HTTP request) between server, make webpage from a small amount of information of Web server request, rather than full page.The user can ask the picture of certain position in some pages in page input picture file request msg, is not limited to the picture that only can ask full page.Can comprise in the picture file request msg: the form of the access path of picture file, the title of picture file, picture file etc., the access path of picture file can be URL(Uniform/Universal Resource Locator, URL(uniform resource locator)) address, the form of picture file such as bmp, jpg, gif, psd etc.
Picture file raw data acquisition module 120 is used for the picture file raw data corresponding according to described picture file acquisition request.In specific implementation, the picture file request that the page that gets according to picture file acquisition request module 110 sends by AJAX can get corresponding picture file raw data, picture file raw data acquisition module 120 can comprise: transmitting element and picture file raw data acquiring unit, wherein, transmitting element, be used for sending described picture file HTTP request bag according to described picture file request to server, described picture file HTTP request comprises the access path of requested picture file; Picture file raw data acquiring unit is used for obtaining the described picture file raw data that server returns according to described HTTP request bag.Web browser is resolved the user in the picture file request msg of page input, generate the picture file HTTP request bag of this picture file, picture file HTTP request bag sends to server end by network, server returns to the picture file raw data according to HTTP request bag, wherein, the picture file raw data is such as binary data of picture file etc.In picture file HTTP request bag, including, but not limited to the access path of requested picture file, picture file HTTP request bag can also comprise the request mode of picture file, as GET/POST, Asynchronous Request etc.Send the step of picture file HTTP request bag to server according to the picture file request, for example, first step: prepare the data of picture file HTTP request bag, the access path URL of requested picture file for example, method: the mode GET of request; Second step: open request, loading data, as using statement: " xmlHttp.open (" GET ", url, true); "; Third step: carry out the preparation of result, as using statement: " xmlHttp.onreadystatechange=dowork; "; The 4th step: send request, as using statement: " xmlHttp.send (null); ".
Picture file processing module 130, being used for decodes to described picture file raw data obtains picture file, and shows described picture file.In specific implementation, server returns to the picture file raw data to after browser according to the HTTP that receives request bag, and browser carries out decode operation and obtains picture file getting the picture file raw data.The page need not to process picture again, the page is by original method ResponseText of XmlHttpRequest, its assignment is given the node (as the reference address of this picture file) that needs to use this pictures file, can obtain and download this picture file raw data, the picture file raw data that gets can be kept in label or input.Further alternative, when again getting the request of this picture file that the page sends by AJAX, can directly call the picture file raw data of having preserved, do not need again to obtain to server request the raw data of this picture file.
Picture file processing module 130 can also comprise display unit, and wherein, display unit is used for obtaining described picture file in the positional information of target pages according to described target pages, shows described picture file according to the described positional information that gets.Display unit is resolved from target pages and is got the positional information of this picture file in target pages, according to this positional information file that Shows Picture, the positional information of this picture file in target pages can be the optional position of target pages, such as in middle position, position, the lower left corner, bottom or the position, the upper right corner, top etc. of target pages, also can confirm concrete positional information take the longitudinal axis transverse axis coordinate of target pages as benchmark.Resolve in target pages and get the positional information of this picture file in target pages, according to this positional information file that Shows Picture, for example, the user asks picture A at page A by AJAX, after browser gets the raw data of picture A, before the A that Shows Picture, first obtain the display position information of picture A in target pages B in target pages B, as picture A display position information in target pages B be: middle position, and then the file A that Shows Picture in the middle position of target pages B.
Further alternative, the system of the request picture file that the embodiment of the present invention provides can also comprise: AJAX object acquisition module 140, wherein:
AJAX object acquisition module 140 is for the object XmlHttpRequest of the described AJAX that obtains page creation.In specific implementation, browser can built-in XmlHttpRequest object, for example by JavaScript code establishing XmlHttpRequest object: " xmlhttp=new XMLHttpRequest (); ".The XmlHttpRequest object is used in backstage and server exchange data, can be in the situation that do not reload more new web page of the page, can be from the server request data after the page loads, can from the server receive data after the page loads, can send data to server on the backstage.Use the XmlHttpRequest object can carry out asynchronous data inquiry, retrieval etc.The XmlHttpRequest object has a simple interface at browser and allows data to be delivered to service end from client, and can not interrupt the current operation of user.
The embodiment of the present invention provides a kind of system that asks picture file, the page can be asked picture file by AJAX, browser can get the picture file raw data of the correspondence that server returns, can also show in the optional position of target pages this picture file, realized and by the asynchronous download pictures file of AJAX and to have shown, under the prerequisite of not upgrading full page, but the picture file in the real-time update page.
The specific implementation of the method for the request picture file that the below's elaboration embodiment of the present invention provides.
Fig. 2 is a kind of process flow diagram of asking the method for picture file in the embodiment of the present invention, and the present invention can realize in the web browser client, asks as shown in the figure the method for picture file to comprise at least:
Step S210 obtains the picture file request that the page sends by AJAX.In specific implementation, the picture file request comprises: the user is in the data of the page by the Asynchronous Request picture file of the object XmlHttpRequest submission of AJAX.Wherein, the core of AJAX is JavaScript object XmlHttpRequest, and AJAX uses asynchronous data transfer (HTTP request) between web browser and Web server, make webpage from a small amount of information of Web server request, rather than full page.The user can ask the picture of certain position in some pages in page input picture file request msg, is not limited to the picture that only can ask full page.Can comprise in the picture file request msg: the form of the access path of picture file, the title of picture file, picture file etc., the access path of picture file can be the URL address, the form of picture file such as bmp, jpg, gif, psd etc.
Step S220 is used for the picture file raw data corresponding according to described picture file acquisition request.In specific implementation, the picture file request that sends by AJAX according to the page that gets can get corresponding picture file raw data, wherein, the picture file raw data corresponding according to described picture file acquisition request can comprise: send described picture file HTTP request bag according to described picture file request to server, described picture file HTTP request comprises the access path of requested picture file; Obtain the described picture file raw data that server returns according to described HTTP request bag.Web browser is resolved the user after the picture file request of page input, generate the picture file HTTP request bag of this picture file, picture file HTTP request bag sends to server end by network, server returns to the picture file raw data according to HTTP request bag, wherein, the picture file raw data is such as binary data of picture file etc.。In picture file HTTP request bag, including, but not limited to the access path of requested picture file, picture file HTTP request bag can also comprise the request mode of picture file, as GET/POST, Asynchronous Request etc.Send the step of picture file HTTP request bag to server according to the picture file request msg, for example, first step: prepare the data of picture file HTTP request bag, the access path URL of requested picture file for example, method: the mode GET of request; Second step: open request, loading data, as using statement: " xmlHttp.open (" GET ", url, true); "; Third step: carry out the preparation of result, as using statement: " xmlHttp.onreadystatechange=dowork; "; The 4th step: send request, as using statement: " xmlHttp.send (null); ".
Step S230 decodes to described picture file raw data and obtains picture file, and shows described picture file.In specific implementation, server according to the HTTP that receives request bag return the picture file raw data to browser after, browser carries out decode operation and obtains picture file getting the picture file raw data.The page need not to process picture again, the page is by original method ResponseText of XmlHttpRequest, its assignment is given the node (as the reference address of this picture file) that needs to use this pictures file, can obtain and download this picture file raw data, the picture file raw data that gets can be kept in label or input.Further alternative, when again getting this picture file request that the page sends by AJAX, can directly call the picture file raw data of having preserved, do not need again to obtain to server request the raw data of this picture file.
Described picture file raw data is decoded obtain picture file, and show that described picture file can also comprise: obtain the positional information of described picture file in target pages according to described target pages, show described picture file according to the described positional information that gets.Resolve from target pages and get the positional information of this picture file in target pages, according to this positional information file that Shows Picture, the positional information of this picture file in target pages can be the optional position of target pages, such as in middle position, position, the lower left corner, bottom or the position, the upper right corner, top etc. of target pages, also can confirm concrete positional information take the longitudinal axis transverse axis coordinate of target pages as benchmark.Resolve in target pages and get the positional information of this picture file in target pages, according to this positional information file that Shows Picture, for example, the user is at the request picture A of page A by AJAX, after browser gets the raw data of picture A, before the A that Shows Picture, first obtain the display position information of picture A in target pages B in target pages B, as picture A display position information in target pages B be: middle position, and then the file A that Shows Picture in the middle position of target pages B.
Further alternative, the method for the request picture file that the embodiment of the present invention provides can also comprise step:
Obtain the object XmlHttpRequest of the described AJAX of page creation.In specific implementation, before step S210, namely before obtaining the picture file request that the page sends by AJAX, browser can built-in XmlHttpRequest object, for example by JavaScript code establishing XmlHttpRequest object: " xmlhttp=new XMLHttpRequest (); ".The XmlHttpRequest object is used in backstage and server exchange data, can be in the situation that do not reload more new web page of the page, can be from the server request data after the page loads, can from the server receive data after the page loads, can send data to server on the backstage.Use the XmlHttpRequest object can carry out asynchronous data inquiry, retrieval etc.The XmlHttpRequest object has a simple interface at browser and allows data to be delivered to service end from client, and can not interrupt the current operation of user.
The embodiment of the present invention provides a kind of method of asking picture file, the page can be asked picture file by AJAX, browser can get the picture file raw data of the correspondence that server returns, can also show in the optional position of target pages this picture, realized and by the asynchronous download pictures file of AJAX and to have shown, under the prerequisite of not upgrading full page, but the picture file in the real-time update page.
One of ordinary skill in the art will appreciate that all or part of flow process that realizes in above-described embodiment method, to come the relevant hardware of instruction to complete by computer program, described program can be stored in a computer read/write memory medium, this program can comprise the flow process as the embodiment of above-mentioned each side method when carrying out.Wherein, described storage medium can be magnetic disc, CD, read-only store-memory body (Read-Only Memory, ROM) or random store-memory body (Random Access Memory, RAM) etc.
Above disclosed is only preferred embodiment of the present invention, certainly can not limit with this interest field of the present invention, and the equivalent variations of therefore doing according to claim of the present invention still belongs to the scope that the present invention is contained.

Claims (10)

1. a method of asking picture file, is characterized in that, described method comprises:
Obtain the picture file request that the page sends by AJAX;
The picture file raw data corresponding according to described picture file acquisition request;
Described picture file raw data is decoded obtain picture file, and show described picture file.
2. method according to claim 1, is characterized in that, described picture file request comprises: the user is in the data of the page by the Asynchronous Request picture file of the object XmlHttpRequest submission of AJAX.
3. method according to claim 1, is characterized in that, the described picture file raw data corresponding according to described picture file acquisition request comprises:
Send described picture file HTTP request bag according to described picture file request to server, described picture file HTTP request comprises the access path of requested picture file;
Obtain the described picture file raw data that server returns according to described HTTP request bag.
4. method according to claim 1, is characterized in that, described described picture file raw data is decoded obtains picture file, and shows that described picture file comprises:
Obtain the positional information of described picture file in target pages according to described target pages, show described picture file according to the described positional information that gets.
5. method according to claim 2, is characterized in that, the described page that obtains comprises by the picture file request that AJAX sends before:
Obtain the object XmlHttpRequest of the described AJAX of page creation.
6. a system that asks picture file, is characterized in that, described system comprises:
Picture file acquisition request module is used for obtaining the picture file request that the page sends by AJAX;
Picture file raw data acquisition module is used for the picture file raw data corresponding according to described picture file acquisition request;
The picture file processing module, being used for decodes to described picture file raw data obtains picture file, and shows described picture file.
7. system according to claim 6, is characterized in that, described picture file request comprises: the user is in the data of the page by the Asynchronous Request picture file of the object XmlHttpRequest submission of AJAX.
8. system according to claim 6, is characterized in that, described picture file raw data acquisition module comprises:
Transmitting element is used for sending described picture file HTTP request bag according to described picture file request to server, and described picture file HTTP request comprises the access path of requested picture file;
Picture file raw data acquiring unit is used for obtaining the described picture file raw data that server returns according to described HTTP request bag.
9. system according to claim 6, is characterized in that, described picture file processing module comprises:
Display unit is used for obtaining described picture file in the positional information of target pages according to described target pages, shows described picture file according to the described positional information that gets.
10. system according to claim 7, is characterized in that, described system also comprises:
AJAX object acquisition module is for the object XmlHttpRequest of the described AJAX that obtains page creation.
CN 201310036033 2013-01-30 2013-01-30 Method and system for requesting picture file Pending CN103150334A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 201310036033 CN103150334A (en) 2013-01-30 2013-01-30 Method and system for requesting picture file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 201310036033 CN103150334A (en) 2013-01-30 2013-01-30 Method and system for requesting picture file

Publications (1)

Publication Number Publication Date
CN103150334A true CN103150334A (en) 2013-06-12

Family

ID=48548412

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 201310036033 Pending CN103150334A (en) 2013-01-30 2013-01-30 Method and system for requesting picture file

Country Status (1)

Country Link
CN (1) CN103150334A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104598616A (en) * 2015-01-30 2015-05-06 百度在线网络技术(北京)有限公司 Page loading method, page loading device, server and page loading system
CN106126595A (en) * 2016-06-20 2016-11-16 浪潮电子信息产业股份有限公司 A kind of document down loading method and device
CN109543437A (en) * 2018-11-30 2019-03-29 人教数字出版有限公司 A kind of load resource allocation method and device

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104598616A (en) * 2015-01-30 2015-05-06 百度在线网络技术(北京)有限公司 Page loading method, page loading device, server and page loading system
CN106126595A (en) * 2016-06-20 2016-11-16 浪潮电子信息产业股份有限公司 A kind of document down loading method and device
CN109543437A (en) * 2018-11-30 2019-03-29 人教数字出版有限公司 A kind of load resource allocation method and device
CN109543437B (en) * 2018-11-30 2020-11-17 人教数字出版有限公司 Resource loading method and device

Similar Documents

Publication Publication Date Title
CN103218434B (en) A kind of method and apparatus loading static resource
CN109542427B (en) System customization method and device, electronic equipment and storage medium
CN100462964C (en) Updating display method for webpage data
CN103942225B (en) A kind of resource transfer method, client and the system of mixed type applications client
US7870482B2 (en) Web browser extension for simplified utilization of web services
CN102027469B (en) Dynamic image composition
CN101147145B (en) Embedded web-based management method
CN111143725A (en) Page generation method and device and electronic equipment
US8682964B1 (en) Progressively loading network content
CN103516787A (en) Method, terminal and system for synchronous display
CN106372175A (en) Method, device and server for processing report forms
CN105095220B (en) A kind of browser implementation method, terminal and virtualization agent device
CN106202368B (en) Preloading method and device
CN102624910B (en) Method, the Apparatus and system of the web page contents that process user chooses
CN103870254A (en) Dynamic form achieving method, client and server
CN108021594B (en) Webpage display method, device and system
US20220407907A1 (en) Web application component migration to a cloud computing system
CN103150334A (en) Method and system for requesting picture file
CN102915371A (en) Method for dynamically referencing files on web page
CN110866202A (en) Front-end paging method and device and readable storage medium
CN114756228A (en) Page processing method, device, equipment and storage medium
CN111460348B (en) File processing method and device
US11126410B2 (en) Method and apparatus for building pages, apparatus and non-volatile computer storage medium
US10530709B2 (en) Container contract for data dependencies
CN112486482A (en) Page display method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20130612