Outcomes
- Using ajax with jQuery.
- Process JSON data.
Scoring
- If the provided web pages in the provided project version cannot be opened or read, your score will be zero.
- Deductions will be made for not meeting the requirements i.e. names of files or folders as requested, functionality.
- Also, see the rubric for more specific grading information.
Repository
- In gitlab, create a new project named 383-H08-<section>-<UID>-FourRandomCharacters, where <section> is your section (A, B, C, D, or E); UID is your unique ID, and FourRandomCharacters are any four random characters.
- Make the following people developers on your project
- All sections: castroa (Instructor)
- Only section A: silwals (Teaching Assistant)
- Only section B, C: wangy75 (Teaching Assistant)
- Only section D, E: yeb2 (Teaching Assistant)
- Clone the project into your web folder (public_html/cse383/).
- Copy the existing form assignment project’s (Homework 07) files to this new folder (do not copy the .git/ folder).
Assignment
- Update the project such that it submits the data via an AJAX post.
- Upon a successful POST the application will receive JSON data which the application will then display.
API
- You will use the following API for POSTING your data.
- url
- ceclnx01.cec.miamioh.edu/~castroa/cse383/homework08/form-ajax.php
- Data Sent
- user: string
- affiliation: string
- comment: string
- car: string
- color: string
- Result:
- data[]
- user
- affiliation
- comment
- car
- color
- timestamp
- status: “OK” or “FAIL”
- msg: String
- if OK, it will also contain data[]
- data[]
- Note: This only responds to a POST request.
Requirements
- Your HTML application will start with the form.
- After validating all inputs (as you already should have done), override the submit so that it makes an jQuery/ajax POST call to the above URL.
- Upon success and if status == ok, hide the form and display the returned data as a table.
- Upon an error, display an error message to the user.
- At the bottom of the page, place a button that will cause the form to be unhidden which will allow the user to enter new form data.
- Make sure you HTML is valid, indented, and well commented
Details
- You must place ALL javascript in an external script file.
- You still must validate the user input via jQuery before calling submit.
- You must check for ajax post errors. I will randomly (about 50% of the time) cause the API to return errors. If you get an error you should show an appropriate message to the user.
Comments
- Making the ajax call.
- You need to make sure to set the content type of the sending ajax when making the call as well as making sure to stringify the data object.
- Then part of the ajax call will look like:
- $.ajax( {
- url: …,
- contentType: ‘application/json’,
- data: JSON.stringify(dataFromForm),
- $.ajax( {