Opdracht 2 Auction

Source: https://github.com/davidcassedie/webdev-opdracht2.int (laravel5.1 PRETTY GOOD)

Installation:

  1. Clone from https://github.com/davidcassedie/webdev-opdracht2.int

     
  2. Then go to ‘webdev-opdracht2.int’ directory
  3. Install required components:
  4. Create a database ‘opdracht2’ via phpmyadmin
  5. Edit/create .env file and set the database configuration
  6. Migrate the required tables
  7. generate the new key
  8. set file permission to 777 for /storage

     
  9. Test it http://localhost:8000/

    NOTE: FOR THE OTHERS ROUTES LIKE http://localhost:8000/auth/register, I GOT BLANK PAGE. THIS IS BECAUSE IN MANY BLADES PAGE IN /resources/views/ (FOR EXAMPLE: /auth/register.blade.php), I FOUND THIS LINE

    CAUSE THE ERROR. SO FOR SAVING TIME, I JUST COMMENTED THE LINE

    PLS DO THIS FOR ALL THE BLADES PAGES CONTAIN THE ABOVE LINE! (IF I HAVE TIME I’D INSPECT WHY /reusable/spotlight.blade.php SHOWS THE ERROR)!!!
    TO SHOW PHP DEBUG IN LARAVEL, PUT

    AT THE BEGINNING OF /app/Http/routes.php FILE!
    BUT IT SHOWED WEIRD ERROR:

    ALSO IT’S IMPORTANT TO SET A FEW REQUIRED INITIAL DATA IN THE DATABASE LIKE FOR ‘countries’ (just input ‘code’: ‘NL’, ‘name’: ‘Nederland’) AND ‘auctionstyles’ (‘name’: ‘Classics’).
    OK. IT SHOULD OKAY NOW. REGISTER FIRST THEN ADD A NEW AUCTION. Here is the screen from http://localhost:8000/myauctionswebdev-opdracht2-int

Laravel Auction

Source: https://github.com/ddichov/PHP (Laravel 4.1. IT SEEMS OLD FASHION & NOT GOOD)

Installation:

  1. Dwonload in zip file from https://github.com/ddichov/PHPThen just get the common laravel directory and rename to ‘laravel-auction’
  2. Install required components:
  3. Create a database ‘laravel_auction’ via phpmyadmin
  4. Set a few configuration settings in /app/config/app.php like

    and the database (Laravel 4 dont use .env file to store the database setting) in /app/config/database.php

     
  5. generate the new key

     
  6. set file permission to 777 for /app/storage

     
  7. Migrate the tables to the database
  8. Open it http://localhost/works/laravel/laravel-auction/public/laravel-auction

Fotista Auction

Source: https://github.com/fotistas/fotista (Laravel 4.2)

Installation:

  1. Clone from https://github.com/fotistas/fotista


    Then go to ‘fotista’ directory
  2. Install required components:
  3. Create a database ‘auction’ via phpmyadmin
  4. Import the sql script ‘auction-20140823-0211.sql’ in ‘/sql archive/’ dir (extract the zip first).
  5. Set a few configuration settings in /app/config/app.php like

    and the database (Laravel 4 dont use .env file to store the database setting) in /app/config/database.php

     
  6. generate the new key

     
  7. set file permission to 777 for /app/storage

     
  8. Make some update on the database, especially for table ‘images’, I need to remove and replace ‘http:\\/\\/localhost\\/auction\\/public\\/uploads\\/’ in ‘images’ field because I just need the image name. No need the url. With this I can show the product image and the thumbnails. I did the replace in my text editor geany instead of on phpmyadmin because it’s easier to do it in geany. Also modified a few files to display the images and the thumbnails properly:
    in /app/views/home.blade.php, replace  ‘$product -> thumbnail’ to ‘{{ URL::to( ‘uploads/’ .  $product -> thumbnail) }}’ (TWICE) like this

    Also the same for /app/views/store.blade.php and /app/views/auction.blade.php. Same also for /app/views/product.blade.php BUT at ‘$product -> large’ like this:

    Also the same for ‘admin’ page: /app/views/admin/products.blade.php, /app/views/admin/product.blade.php, /app/views/admin/auction.blade.php.
  9. Open it http://localhost/works/laravel/fotista/public/fotista-frontThe admin page http://localhost/works/laravel/fotista/public/admin/
    http://localhost/works/laravel/fotista/public/admin/productsfotista-admin-productlist
  10. SOME ERRORS & SOLUTION:
    The first time, I got this error:

    SOLUTION: It because I forgot to set the file permission at #7 (ref:http://stackoverflow.com/questions/24982598/laravel-error-in-exception-handler)
    NOTE: To get better debug environment, I need to set ‘debug’ to ‘true’ in /app/config/app.php!

    After that I got another error:

    SOLUTION: That because I forgot to set a new key like at #6 (ref:http://laravel.io/forum/04-22-2014-whoops-looks-like-something-went-wrong-with-new-installation)
    NOTE: For laravel 4, No need to create .env file like laravel 5
    Then I got another error:

    SOLUTION: I forgot to set the database setting in /app/config/database.php like at #5 (ref: http://laravel.io/forum/07-02-2014-sqlstatehy000-1044-access-denied-for-user-localhost-to-database-forge?page=1)

UNSOLVED ERROR:
When I tried to click ‘Auction started click here to open it’. It didn’t work. It did open a new page but do nothing. Just printed ‘Loading…’. From the console, it’s looking for a file in http://localhost/works/laravel/fotista/public/api/auction BUT THERE IS NO /public/api/auction DIR AVAILABLE!
The controller responsible for this is /app/controller/AuctionController.php, The view is /app/views/auction-app.blade.php and the javascript file in /public/js/auction-app.js
HOW TO MAKE THE AUCTION FULLY WORKS???? ESPECIALLY THE ANGULAR JS ‘auction-app.js’???
PLS TRY THIS GITHUB: https://github.com/yervand951/angular-auction
CONVERT TO LARAVEL 5 ???? ref: https://mattstauffer.co/blog/upgrading-from-laravel-4-to-laravel-5 and https://laravel.com/docs/5.0/upgrade.

Laravel Quiz

source: https://github.com/SAIBA0011/laravel-quiz

Description:

Laravel-Quiz functionality

Create a new quiz
Create quiz questions — single & multi Select
show quiz questions
Create quiz question options — Pending..
To be implemented

Finish quiz question options.
Change question position.
Change question option position.
Randomize question order on display page.
Track user attempts per quiz.
Allow user to take quiz.
allow user to complete quiz.
show quiz results on complete.

Installation:

  1. Create a new laravel project:

     
  2. Download the app from https://github.com/SAIBA0011/laravel-quiz. It’s better to donwload in zip file then extract the content in /works/laravel/quiz/ directory. Overwrite the existing files and directories.
  3. Install the laravel component required:

     
  4. Create a new database ‘laravel_quiz’ by phpmyadmin
  5. Use ‘php artisan migrate’ to create the tables.
    NOTE: I got this error when trying to do ‘migrate’
    “teddy@teddy-K43SJ:~/Documents/works/laravel/laravel-quiz$ php artisan migrate
    Migration table created successfully.[Illuminate\Database\QueryException]
    SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i
    n your SQL syntax; check the manual that corresponds to your MySQL server v
    ersion for the right syntax to use near ‘) on delete cascade’ at line 1 (SQ
    L: alter table quiz_results add constraint quiz_results_user_id_foreign
    foreign key (user_id) references users () on delete cascade)
    [PDOException]
    SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error i
    n your SQL syntax; check the manual that corresponds to your MySQL server v
    ersion for the right syntax to use near ‘) on delete cascade’ at line 1 ”
    SOLUTION: At first, I did like in the articles http://stackoverflow.com/questions/26820788/add-on-delete-cascade-to-existing-column-in-laravel and http://stackoverflow.com/questions/28167329/laravel-migration-remove-ondeletecascade-from-existing-foreign-key on ‘2016_10_24_101046_create_quiz_results_table.php’ in /database/migrations/ directory BUT SOMEHOW IT DIDN’T WORK

    SO I JUST COMMENT THE ‘onDelete’ COMMAND

    THEN THE MIGRATIONS RUN WELL.
  6. generate the new key
  7. Install npm modules and gulp

    BUT SOMEHOW I GOT THIS ERROR ON ‘gulp’

    NO SOLUTION YET:
    I’VE TRIED FROM https://laracasts.com/discuss/channels/elixir/laravel-53-error-on-gulp-execution?page=1

    BUT FAILED AND GOT THIS ERROR

    I ALSO TRIED (DONT DO THIS BECAUSE I BROKE THE ENVIRONMENT BINDING!)

    BECAUSE OF THIS I GOT A HARDTIME AND SPENT MANY ERRORS TO FIX IT (http://stackoverflow.com/questions/37324519/node-sass-does-not-yet-support-your-current-environment-linux-64-bit-with-false) THROUGH THIS:

    BUT THE ERROR STILL PERSIST (ON GULP)! DONT KNOW HOW TO FIX IT!!!
    I READ gulpfile.js IN ‘laravel-quiz’ PROJECT DIFFERENT WITH IN ‘quiz’ PROJECT. THEREFORE ‘laravel-quiz’ PROJECT USE VUE!!!
  8. Test it live (http://localhost:8000)laravel-quiz-homeIT RUN WELL
  9. Errors & Solutions:
    When I want to see the quiz result by submitting the answer (http://localhost:8000/second-quiz/submit), I got this error:
    “ErrorException in QuizResultsController.php line 25:
    Trying to get property of non-object”
    SOLUTION: This is because I didn’t login first. Use http://localhost:8000/home to login/register (I’ve registered with email: ‘advcha@yahoo.com’ and password: ‘satria’) then take the quiz again and answer the above question. Then the result would be showed up like this:laravel-quiz-result
  10. Others samples for online quiz:
    http://practice.cappassessments.com/Nrt/NrtPage.html (Shows time to answer question, can drag up or down the answer options, not only can pick the answer, but also can type the answer). There is a job application in upwork for this kind of online quiz: https://www.upwork.com/jobs/_~01d2316bc1f3c2cb84/.

Quiz

source: https://github.com/sms516/quiz
online: http://dojang.nz/

Installation:

  1. Create a new laravel project:

     
  2. Download the app from https://github.com/sms516/quiz. It’s better to donwload in zip file then extract the content in /works/laravel/quiz/ directory. Overwrite the existing files and directories.
  3. Install the laravel component required:

     
  4. Import the database file (DB_SETUP.sql) along with the github.
    NOTE: ‘quiz_details’ table can’t be created because the field type ‘datetime CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP’ for ‘updated_at’ can’t be used. So replace ‘datetime’ with ‘timestamp’
  5. Set the file/folder permission for ‘storage’
  6. Test it live (http://localhost:8000/admin)

    WORKING!!!quiz-frontCAN’T SHOW http://localhost:8000/admin BUT CAN SHOW http://localhost:8000/admin/quiz/questionsquiz-admin-questionNOTE: Check the routes in /app/Http/routes.php. The routes are very limited! NO ROUTE FOR ADMIN???
  7. I found gulpfile.js in the root of the website, so I think I need to use npm and gulp to compile the saas:
    Use ‘npm install’ to install required modules

    Use ‘gulp’ to compile saas

    I DONT KNOW HOW TO DO NEXT OR HOW THE NPM AND GULP AFFECT THE WEBSITE! NEED TO LEARN ABOUT THESE!!!
  8. On the homepage ‘http://localhost:8000’, I clicked ‘Start Quiz’ button but I got NOT FOUND error (ajax error) at the chrome console. I found it is triggered by ‘onclick=”startQuiz()”‘ in /resources/views/quiz/view.blade.php and the javascript command in /public/js/functions.js. I NEED TO MODIFY A FEW SETTING IN functions.js file! First replace the ‘base_dir’ variable like below:

    FROM NOW ON, I HAVE TO USE ‘http://localhost/works/laravel/quiz/public/’ INSTEAD OF ‘http://localhost:8000’! FOR HOMEPAGE AND ‘http://localhost/works/laravel/quiz/public/admin/quiz/questions’ FOR ADMIN PAGE!
    NOW THE AJAX IS WORKING!! ‘Start Quiz’ button IS WORKING!
    Another errors detected:

    Sometimes I got unknow error when trying to edit the question (http://localhost/works/laravel/quiz/public/admin/quiz/question/376).
    Solution: I need to put ‘ini_set(‘display_errors’,1);’ in /app/Http/routes.php to enable to debug the errors. It seems the ‘storage’ directory HAS NOT BEEN SET THE PERMISSION. So make sure the step #5 is executed first!
  9. Improvements:
    Many links in the admin page can’t be opened or don’t have the correct routes. Here I want to fix or develop the links.
    Club Admin (http://localhost/works/laravel/quiz/public/admin/club)
    Add a new route in /app/Http/routes.php

    Create a new controller ‘ClubController.php’ in /app/Http/Controllers/

    The ‘Club’ model is already exist in /app/models/ directory! Here we want to show all the club in our database!
    The data would be showed up by /resources/views/club/view.blade.php like this:quiz-view-clubsAdd/Save New Club (http://localhost/works/laravel/quiz/public/admin/club/add)
    Add two new routes in /app/Http/routes.php

    Modify a controller ‘ClubController.php’ in /app/Http/Controllers/

    Add/modify a model ‘Club.php’ in /app/models/ directory:

    Add new model ‘MartialArt.php’ in /app/models/ directory:

    Add a new blade template ‘add.blade.php’ in /resources/views/club/ directory

    OK. then make a test at http://localhost/works/laravel/quiz/public/admin/club/add.quiz-add-clubI got this club sample from Kumgang Tae Kwon Do website. Then save the data by clicking ‘Add Club’. Here is the working result:quiz-club-savedEdit/Save Club (http://localhost/works/laravel/quiz/public/admin/club/edit/4)
    First I need to put ‘Edit’ link on the club admin page (http://localhost/works/laravel/quiz/public/admin/club). Modify ‘view.blade.php’ in /resources/views/club/ directory. Modify the header table to show/hide the needed field (add class ‘all’ to show and ‘none’ to hide)

    Then arrange the field width by defining the columns (‘columnDefs’) like this:

    So here is the new looksquiz-club-view-editTo make the ‘Edit’ links work, add two new routes in /app/Http/routes.php

    Then Modify ‘ClubController.php’ in /app/Http/Controllers/ dir:

    Add/Modify ‘edit.blade.php’ in /resources/views/club/ directory:

    OK. Now the Club admin can be used properly.
    NOTES: When I save the new club or the edited club, I don’t find the flash status to show the data is saved/updated successfully!
    HOW TO DELETE CLUB???

Sistem Informasi Sekolah (SIS)

Source: https://github.com/balitax/SI-Sekolah-L5

Installation: (the most steps is pretty same with Laravel Blog)

  1. Create a new laravel project:

     
  2. Download the app from https://github.com/balitax/SI-Sekolah-L5. It’s better to donwload in zip file then extract the content in /works/laravel/sis/ directory. Overwrite the existing files and directories.
  3. Install the laravel component required:

     
  4. edit .env file and fill the database account (DB name is sis)
  5. Import the database file (database_sekolah.sql) along with the github.
    Note: authentication scaffolding NOT RUN HERE! ERROR BUT NO PROBLEM
  6. Use ‘migration’ to add some new tables into the new database

     
  7. Dont forget to set the file permission in /public/ directory if we want to upload an image into it

     
  8. I found some errors when tried it for the first time. http://localhost:8000/login IS WORKING but CAN’T LOGIN. THE USER TABLE IN ‘tbl_kepegawaian’. BECAUSE I DONT KNOW THE ‘admin’ PASSWORD, I NEED TO UPDATE ‘password’ FIELD WITH ‘$2y$10$eWW.aZOeruiS1VEO0ghKHu7A7UoQcj2tVmLIcnw6JnrcsiljuOmYK’ –> ‘satria’. SO the ‘admin’ password is ‘satria’. NOW I CAN GO INTO THE ADMIN PAGE (dashboard, data sekolah, data siswa, galeri foto, absensi siswa, data pegawai, etc).
    THERE ARE SO MANY ERRORS (I CAN’T GO INTO THE WEBSITE ROOT OR http://localhost:8000/ BUT ONLY CAN GO TO http://localhost:8000/admin). ANYWAY IT’S GOOD AND I CAN SEE THE SCREEN!
    NOTES: pls study the routes in /app/Http/routes.php !

SOMETHING IS NEEDED TO FIX SOME ERRORS:

  1. Error when I want to acces the root http://localhost:8000/
    “FatalErrorException in Handler.php line 25:
    Uncaught TypeError: Argument 1 passed to App\Exceptions\Handler::report() must be an instance of Exception, instance of Error given, called in /home/teddy/Documents/works/laravel/sis/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php on line 73 and defined in /home/teddy/Documents/works/laravel/sis/app/Exceptions/Handler.php:25
    Stack trace:
    #0 /home/teddy/Documents/works/laravel/sis/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(73): App\Exceptions\Handler->report(Object(Error))
    #1 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleException(Object(Error))
    #2 {main}
    thrown”
    SOLUTION: The error because I use PHP 7 (CLI) when I started the server (‘php artisan serve’). ref: http://stackoverflow.com/questions/36983734/laravel-fatalerrorexception-in-handler-php-line-25. So use php 5.6 instead when starting the server like this:
  2. Another error when accessing the root website:
    “FatalErrorException in FrontController.php line 42:
    Class ‘App\Models\Banner’ not found”
    SOLUTION: In /app/Http/Controllers/FrontController.php, comment a few lines:

    Because there is models available for them.
    Also in ‘index’ function, replace ‘bappeda’ with ‘web’

     
  3. Now, the root/front website can be displayed but the website can’t be loaded. User need to upload the logo manually from the admin page -> Setting (http://localhost:8000/admin/setting). But when I saved the input, This error is appeared:
    “QueryException in Connection.php line 624:
    SQLSTATE[42S22]: Column not found: 1054 Unknown column ‘peta_latitude’ in ‘field list’ (SQL: update tbl_setting set title_web = Sekolah Ku, desc_web = Sekolah Ku, key_web = sekolah, logo = lapVa94436orMdu892YPf3uSj931XM.png, facebook = , twitter = , gplus = , peta_latitude = , peta_longitude = , alamat = , no_telp = , no_fax = , email = where id_setting = 1)”
    SOLUTION: Modify tbl_setting in the database, then add these new fields: peta_latitude varchar(25), peta_longitude varchar(25), alamat text, no_telp varchar(25), no_fax varchar(25) and email varchar(25).
    Now the website logo can be displayedsis
  4. When I clicked one of the news (berita) like http://localhost:8000/baca/berita/2011-lembaga-pemerintah-sudah-harus-cicipi-open-source, I got this error:
    “InvalidArgumentException in FileViewFinder.php line 140:
    View [bappeda.berita_detail] not found.”
    SOLUTION: in /app/Http/Controllers/FrontController.php, Modify ‘berita’ function and replace ‘bappeda’ with ‘web’ and ‘berita_detail’ with ‘beritadetail’

     
  5. When I clicked one of the ‘Profil Sekolah’ links like http://localhost:8000/page/profil-sekolah, I got this error:
    “InvalidArgumentException in FileViewFinder.php line 140:
    View [bappeda.halaman] not found.”
    SOLUTION: SAME WITH ABOVE, Modify ‘halaman’ function in FrontController.php and replace ‘bappeda’ with ‘web’:
  6. Some links still shows error like for ‘pengumuman’ (http://localhost:8000/baca/pengumuman/pembagian-raport-semester-ganjil-tahun-ajaran-2010-2011) –> check the route and make sure the model is exist
    SOLUTION: There is no ‘pengumuman’ route, so add them (also for pengumuman index and detail) in /app/Http/routes.php like this:

    Then in FrontController.php, like above replace ‘bappeda’ with ‘web’ for ‘pengumumanlist’ and ‘pengumuman’ functions:

     
  7. For Galleri menu, do this:

     
  8. Some pages in the admin (http://localhost:8000/admin) still can’t be showed up properly (some weirds characters appeared!)

Laravel Blog

  1. Create a new laravel project:


     
  2. Download the ready made laravel blog app from https://github.com/jacurtis/laravel-blog-tutorial. It’s better to donwload in zip file then extract the content in /works/laravel/laravel-blog-tutorial/ directory. Overwrite the existing files and directories.
  3. Install the laravel component required:


     
  4. edit .env file and fill the database account (DB name is laravel_blog)
  5. Create authentication scaffolding (login, register, forgot password, etc)
  6. Use ‘migration’ to add some new tables into the new database

    It should be ready to test the website.
  7. Dont forget to set the file permission in /public/ directory if we want to upload an image into it
  8. Test the website: http://localhost:8000/

    If i found an error like:

    Just stop the server then generate the new key:

    It’d create a new key in .env like

    ref: http://laravel.io/forum/08-25-2016-no-supported-encrypter-found-the-cipher-and-or-key-length-are-invalid-when-i-run-keygenerate.
    Then start the server back. If everything is okay, here is the screen look like:blog-tutorialSometimes you got an error about the file permission writeable or not like this

    Then you need to set the file permission in /public/ directory to 777

    Explore the Laravel Blog!!! (Add/edit users, add/edit posts, categories, tags, comments, send contact, login, register)
    If you have enough time to learn the nitty-gritty about laravel and how to create this blog step by step, then please watch this 47 youtube videos in How to Build a Blog with Laravel.
  9. NOTES about this app:
    The route file DONT lay in /routes/web.app BUT in /app/Http/routes.php. It used Route::group.

    The route for the root website (/) is pointing to ‘PagesController.php’ in /app/Http/Controllers/

    The ‘Post’ data is retrieved with a help from ‘Post’ model in /app/Post.php. The data then would be rendered by welcome.blade.php in /resources/views/pages/

PHP Tools

Install some PHP tools:

  1. PHP Coding Standards Fixer (http://cs.sensiolabs.org/)
    Installation: (Globally (Composer))

    Then make sure you have ~/.composer/vendor/bin in your PATH and you’re good to go:

    To find out the location of php-cs-fixer

    I can use the location for the netbeans plugins needed.
    Another reference: https://mattstauffer.co/blog/using-php-cs-fixer-to-fix-up-your-php-code
  2. PHP CodeSniffer
    Ref: http://purencool.com/install-and-test-phpcodesniffer-on-ubuntu
    http://askubuntu.com/questions/572956/adding-a-standard-to-php-codesniffer
    Installation:

    To find out the location

    To verify PHP_CodeSniffer is already installed, check like this:

    Ref: https://wisdmlabs.com/blog/how-to-format-php-code-to-wordpress-coding-standards-in-netbeans/
    To use it in netbeans, click: Source > Inspect…
  3. PHP Mess Detector & PDepend
    Ref: https://phpmd.org/download/index.html
    http://stackoverflow.com/questions/27958289/what-is-phpmd-and-how-to-use-it
    Installation: (Same way with php cs fixer to use composer globally)

    To find out the location for PHPMD and PDepend:



     
  4. PHP Copy/Paste Detector (PHPCPD)
    Ref: https://github.com/sebastianbergmann/phpcpd
    NOTE: DONT INSTALL FROM PEAR!
    Installation: (Use composer globally)

    To find out the location:

    Please read this: Installation of PHP Code Review Tools
    For integrating all the above tools in Netbeans!

JQuery Promise Cascase To Array Reduce

I have a question about JQuery Promise problem. Actually I have a more difficult problem about the JQuery and Ajax that I need to loop a result from Ajax call then nest it to call another Ajax. But I dont know how to set a delay/timeout between the Ajax calls so I can avoid to put much burden on the server. I want to simplify the problem so I can comprehend the promise better. I have a working function to write some console outputs but the output has to be written after delaying for 2 seconds. Here is the code

And here is the output

The above code actually I borrowed from http://jsfiddle.net/1njL4w1t/. NOTE: Learn carefully also about the promise error handling Problems inherent to jQuery $.Deferred (jQuery 1.x/2.x).
Now I want to replicate the same behavior but I want to use array reduce here. I have tried many things to achieve that by searching through internet but can’t wrap them up in my brain. Then I asked the problem on stackoverflow. Here is my initial code

BUT it didn’t work like I want. Then I got the working solution from one of the stackoverflow user. Here is the answers (yeah I got two working answers)

And it’s work like I want. I made a test file (promise-timeout.php) and try it locally http://localhost/works/jquery/promise-timeout.php.

Now I want to make it more difficult by using ajax. I made two functions (‘getCarQueryMake’ and ‘getCarQueryModel’) to call the ajaxs like this:

Here is the url value

I created a new file ‘ajax-json.php’ to call the carquery API.

Finally after learning more from the previous sample how to setup the promise and the time out, I can manage how to setup the promise to ajax calls and the timeout to delay every ajax calls. Here is the code:

I made a local test file (promise-timeout2.php) and url: http://localhost/works/jquery/promise-timeout2.php. Here is the console output:

Here is the API url to get Car Models from Car Make: http://www.carqueryapi.com/api/0.3/?callback=1481095214&cmd=getModels&make=abarth
The API response look like:

Okay. Then I expand and add more nest to get Car Serie from Car Model. Also add a delay 5 second between the ajax call to get the Car Serie/Trim. I added a new function ‘getCarQuerySerie’. The function consist of some return function and the delay/timeout. Here is the code

I need to call this function like this

Modify ajax-json.php file to handle the ajax call

I made a test file (promise-timeout3.php) and the url: http://localhost/works/jquery/promise-timeout3.php. Here is the console output (Here I only use one Make. It’s ‘AC’ because the others Makes has many models and series. ‘AC’ only has 8 models):

Here is the API url to get Car Series/Trims from Car Models: http://www.carqueryapi.com/api/0.3/?callback=1481095214&cmd=getTrims&make=abarth&year=-1&model=1000&full_results=0
Then one of the Car Series/Trims output:

NEXT. I need to update the local database also from the APIs but I think it’d need more time to make the local database as complete as CarQuery database. Like I said previously, I dont want to burden the CarQuery server from the API requests! May be I need to increase the delay from 5 seconds to 10 seconds each API request??? Also need to add progress bar and how to handle/catch any error???