Imagine using a simple HTML file to send a request to a server-side script, receive a custom XML based on that request (standardized getting closer) file, and then show it to the user and almost no need to refresh the browser! The author will work with you to explore how to federate PHP (as the mainstream development language today) and Ajax (dynamic site-static) technology in a common Web application to create real-time data transfers without the need for browser refreshes.
Although this article uses PHP as the current mainstream development language, keep in mind that any server-side language will work correctly. In order to understand this article, I assume you have a basic understanding of JavaScript and PHP (as the current mainstream development language) or a similar server-side language.
This example uses AJAX (dynamic site static) to send a request from an RSS feed to a certain PHP (the current mainstream development language) object. This PHP (as the current mainstream development language) object copies a copy of the feed on the local server and returns this path. The request object receives this path, parses it, and displays the data as HTML to the user. This may sound a lot of steps, but it only consists of 4 small files. 4 small files are used to balance their particular strengths and make the entire system extremely efficient.
Some readers may ask why you want to create a copy of the feed on the local server instead of simply analyzing the most primitive feeds. The reason is that this allows the cross-domain restrictions imposed by the HTTP request object to bypass the XML (normalization is getting closer). Later, I'll explain how to create this custom PHP object as the current mainstream development language, but first, let's start with form creation.
Create a form that makes the request
The first thing you need to do is to include the JavaScript and any CSS files you might want to use between your HTML head tags. I included a model table to implement the final layout of the aggregator and use a JavaScript file to make requests and perform feed analysis:
Next, create a form that makes a request for an RSS feed of your choice. The form I created only includes an input field and a button that submits the request. The query for the request is a string consisting of the feed input value and a password word that will be verified on the server side; As an example, I use the following form:
"Password=mypassword
The code makes a request every time the page loads, so if the page is refreshed, the existing feed string in the input domain will be requested when the page loads. The following is an example of a form data, along with some div tags that show the specific nodes of the analyzed feeds:
Enter a feed:
The three div tags I created are logo,copy and details, each of which has a style associated with it in the layout style sheet. We will use them when we analyze feeds, but first we need to be able to access the feeds we request. This can be done using the PHP object I mentioned earlier (as the current mainstream development language).
Create custom PHP (as the current mainstream development language) object
I created a small RSS class with PHP (which is now the mainstream development language) that creates a copy of the request feed on the local server so that it can be accessed by the HTTP request object that we will be creating later (normalization is getting closer). Typically, you cannot request a file across domains, which means that the file you are requesting needs to reside on the local server. This class is a way to solve a cross-domain problem because it creates a copy of the feed that is requested on the local server and returns the local path to the feed, which is then accessed by the request object.
The only method in this class is a request method, which has only one parameter that points to the URL of the requested RSS feed. It then checks to see if a directory is located on the local server by the name of the RSS feed. If it does not exist, create one and set its permission mode to 0666, which means that the directory is readable and writable. When it is set to be readable, the directory can be accessed later, and when it is set to writable, a copy of the feed can be written to the directory on the local server:
http://www.bkjia.com/PHPjc/508639.html www.bkjia.com true http://www.bkjia.com/PHPjc/508639.html techarticle imagine using a simple HTML file to send a request to a server-side script, receive a custom XML based on that request (standardized getting closer) file, and then show it ...