Provide the results of the inspections for the City of London to you in JSON format.

Introduction For this assessment, you are going to use JQuery and AJAX to make a dynamic web page that communicates with a server-side script that we have developed for you. The Food Standards Agency makes the results of restaurants’ (and other businesses serving food) hygiene inspections publicly available (see here:, and we have developed a simple PHP script that will provide the results of the inspections for the City of London to you in JSON format. Requirements & constraints: You should contain all of your work on this assignment in a single HTML file. Use CSS embedded in the page’s header for formatting, likewise for your JavaScript code. You must use the JQuery library (no plain Javascript) and, if you wish, JqueryUI and the validation plugin. You cannot use any other JQuery plugins, or any other JavaScript libraries. You should submit your single HTML file via moodle before the deadline. The Server-Side Script The server-side script is hosted at the following URL: The script can be manipulated using several GET parameters, appended on to the end of the URL. Accessing the script without any parameters returns the first 10 businesses’ ratings in JSON format for testing. The parameters accepted by the script are documented in the table below. Parameter Name Description Op This is the most important parameter, controlling what type of information the script is to return. The op parameter can be set to one of the following values: demo Returns the first 10 businesses’ ratings (default operation) retrieve Returns a “page” of (40) results. Expects the page parameter pages Returns how many pages of results are available searchname Returns the first 40 records for businesses whose name contain the specified search term. Expects the name parameter. Page Used only by the retrieve operation. Expects an integer specifying which page of results to retrieve. For example, page=2 would return the 2nd page of results. Name Used only by the searchname operation. Expects a string specifying the search term business names are to be matched against.

Examples: These parameters make the script retrieve the 7th page of results. These parameters make the script find businesses whose names contain the string “Eat”. JSON Format of Returned Data The demo, retrieve, and searchname operations all return data in the same JSON format. The format is an array of individual JavaScript objects, with each object having the following properties: id The ID of the inspection record. business The name of the business inspected. address The address, including post code, of the business inspected. rating The rating (out of 5) awarded to the business. date The date on which the inspection was carried out. The pages operation returns a single JSON object, with a single “pages” property. This property contains the number of pages of results that are available. Accessing the Script The script outputs special HTTP headers, called Cross-Origin Resource Sharing (CORS), which will allow your browser to access the script using AJAX requests regardless of where your HTML file is apachetl -td, in spite of the same origin policy. This means that you can complete this work from home without needing a webserver or database. We have hosted the script on a publicly-accessible webserver, so you don’t need to use the VPN either. Because of the way these headers are interpreted by your browser, you must use the form of URL given above. Leaving out the www., or changing people/staff/lb514 to ~lb514 will cause the CORS to fail. Note that CORS is not supported out of the box on Internet explorer 9 or earlier, so to test your code you need to use Internet explorer 10, Firefox or a recent version of Chrome. Task 1 – Retrieving the First Page of Results When the Page Loads (30%) Write an HTML page containing a title, some text explaining what the page does, and an empty table. Use JQuery and an AJAX request to the server-side script to populate the table with the first page of results when the page loads. You may omit the id of the inspection record in your table. The screenshot below shows you what the output might look like.

Task 2 – A Basic Paginator (30%) Your page should now perform an additional AJAX request when the page loads. This request should find out the number of pages of inspection results that are available from the server-side script. Once you have found this out, create a row of buttons, one for each page. Each button should be labelled with a page number.

Task 3 – Search Functionality (30%) Add a form to the bottom of your search page containing a text input and a search button. When the user enters text in the text input and clicks the button, your page should clear the results table, perform an AJAX request to the server-side script to retrieve any relevant results, and display them. The screenshot below shows you what your form might look like.

Type of paper Academic level Subject area
Number of pages Paper urgency Cost per page: