CodeIgniter from Scratch Day 8: AJAX

CodeIgniter from Scratch: Day 8 – AJAX

This entry is part 8 of 17 in the CodeIgniter From Scratch Session
« PreviousNext »

The CodeIgniter from Scratch series was unexpectedly, and significantly popular. Today, I’m pleased to announce that, with the help of one of my best authors, Burak, we’ll be continuing the series! Additionally, the most often requested topic is the subject for today’s screencast: combining CodeIgniter and jQuery.

Remember, it is not required that you watch the previous lessons in order to understand today’s screencast. It’s a self-contained article. However, if you’re new to CodeIgniter, we do recommend that you start from the beginning!

Catch Up

Day 8: AJAX

Other Viewing Options

Add Comment

Discussion 159 Comments

Comment Page 1 of 21 2
  1. Oh, it’s sad to see Jeffrey go from these tut’s, they were (still are) so good. Will give this a good watch later.

    Is Jeffrey coming back?

  2. Jamie says:

    Yay!

    Finally, good to see such a great series kick started.

  3. must says:

    Love this serie ! happy that it’s back once again :D

  4. cem says:

    Selam Burak Çalışmaların çok güzel hep takip ediyorum başarılarının devamı dileğiyle.Türkiyeden Selamlar…

    Nice tutorial.

  5. Oh guys you saved my life!
    We’ll miss Jeffrey!!!

  6. Ben says:

    This serie is a must-follow. I’m glad someone took the lead of it. Burak is a pretty good teacher too! I admit I miss Jeffrey though. He’s a codestar!

  7. Great tutorials and good series for learning codeigniter
    thanks

  8. Ben says:

    Oh hello welcome back!!

    Good to see them live on!

  9. Alistair says:

    Definitely going to miss Jeff on this one, however understandably a very busy guy.

    Good work Burak, maybe liven it up a bit?

  10. Adi says:

    Thank you Burak Guzel!
    I’ll miss Jeffrey’s voice though :)

  11. Vitesse says:

    OMG!!

    Please Burak don’t stop this series again…

    Thankyou!

  12. Adrian says:

    Thanks so much for continuing the series, are you still going to follow the original plan of building a full featured blog?

  13. Kinsbane says:

    Smashing Magazine yesterday had an article related to developing AJAX solutions. One of their methods of detecting a jQuery AJAX request uses the header that jQuery sends along when it makes the request:

    if($_SERVER['HTTP_X_REQUESTED_WITH']==’XMLHttpRequest’){
    This is content requested by AJAX.
    }

  14. This is great! I’ve just started a project with CodeIgniter and thanks to this series it’s going amazingly fast. Ajax in CI was the next thing I had to implement in the project.

    Keep up the great series!

    • Khalil says:

      Yes I vote for this great series…

      Please share Codeigniter + Doctrine Screencast Series…

      • Bretticus says:

        That would be excellent. That has my vote. Anyone Listening? @BrianDHall if you frequent these, you’re my vote to do this tutorial (I’m sure you have time.) :)

  15. Hasn Ditri says:

    This tutorial is horrible i’ve been jQuering for months and using jQuery’s ajax functions very well.

    This is just horrible.

    • Hasn Ditri says:

      he could have for example just used this.action in the jQuery’s url:
      field.

      • Burak says:
        Author

        Actually that is not good either. It will conflict with input values named ‘action’, which is quite common. Correct use is this:

        url: $(this).attr(‘action’)

        Is there any other reason that the tutorial is “horrible”?

  16. Rich says:

    Perfect timing! I’m building a social app in CodeIgniter and was just looking into adding AJAX to it this morning.

  17. Brad says:

    Good tut Burak, I dont know Ajax or Jquery but will try to learn it through tuts like this.

    You do however need to learn to open and close programs real fast like Jeffery did, keeps us on our toes. :)

  18. Loved this tutorial.

    The next codeigniter tutorial should be about Hooks or Security!

  19. lawrence77 says:

    Burak has cold??

    Meanwhile a nice tut,

  20. lawrence77 says:

    34min screencast is only 50MB with some nice Quality…

    Nice RIP! Thanks :)

  21. Chris says:

    Awesome!

  22. Vukan says:

    What about tutorial for multi language site with database ? I

  23. Karthik says:

    Ah, Thanks Burak, Jeffrey Way seems to be busy these days ;)

  24. Mini0n says:

    A
    W
    S
    O
    M
    E

    Thanks! =D

  25. arnold says:

    Wow its been a long time …. no sign of Jeff but its cool ,,
    thanks Burak ,

    NO MORE CODE IGNITOR TUTORIALS
    @enatom , why?

  26. Eric says:

    Great job Burak,

    CIfS will be safe in your hands.

  27. Natrium says:

    finally :-)
    I have been waiting for ages for the next day :-)

    Please show us how to use components from the Zend-framework.

  28. Would love to see some cakePHP tuts as well!

  29. aryan says:

    WOW! We all were waiting for this. Thanks a lotttttttttttt.

  30. Walter says:

    I’ve been waiting sooooooooooo long for this series to be continue.
    Many Thanks

  31. PureLife Studio says:

    Burak, thanks for the screencast. I’ll watch it today. Nice move, Jeffrey, to let Burak continue the series, smart move in this troubled times for NetTuts :)

    I have 2 questions, though, for Burak: Do the messages set in the validation rules appear back when the form is submitted? I tried once to combine jQuery AJAX with CI. It was a form with form_validation rules. It didn’t work for me then.

    And another: It is possible to have ONE controller to send back a message to the same view if the form in the view was submitted successfully? I mean, if the form is sent correctly, I don’t want to load another view, just put a message above the form: SUBMITTED.

  32. Rime says:

    Great! I’m glad to see new tutorials about CI!

  33. woony says:

    yay! happy to see this series come back to live!
    Keep de CI tuts coming!

  34. Ignas says:

    dudes… throw out CI… I think you must use framework which is strict PHP5… why? Because of the future… PHP4 is old and I think must die as fast as it can be… Stop using PHP4 and frameworks compatible with it. Yes CI is easy to learn, but it’s hard to customize this framework for specific tasks and this framework still supports PHP4! This is two main disadvantages why I’m stop to learn and use CI.

    • Walter says:

      I think I must to use Codeigniter. Because its documentation es great, because its forum is great, because there are plenty of tuturial out there, and, YES, because is easy to learn.
      It supports PHP4, but using php4 or not is up to all of us. Has nothing to do with codeigniter itself.

    • Burak says:
      Author

      It’s a good framework for beginners, well documented and has a big community. But I somewhat agree that it is not future-proof.

      • PureLife Studio says:

        This is where Zend comes in and says `hello, how may I serve you?` :)

      • Walter says:

        But, if I develop a app which is running in a PHP5 server and everything work just right, why could this app be not future-proof, since it’s already running over a PHP5 server. Can’t see your point guys.

    • Ignas says:

      If framework still supports php4 it means that this framework is not using functions which is only in PHP5 and as you know there are a lot usefull things in PHP5. Or you think PHP5 is still the same as PHP4 and don’t have functions which was improved or it is just new functions? Of course I’m talking about the core of framework, because other parts which will be written by you, can use these. But common, why I should use framework with the core written in the way which is still runs on PHP4…

    • DKline says:

      Hey man I totally agree with you. If you guys are gonna use CI, then only use it as a stepping stone. I moved into Kohana from CI and I think Kohana is great and will hold up much better in the future than CI.

  35. Lacoasta says:

    Hey Burak, really enjoyed the Tutorial, could you go a step a head and show us how to put the contact message in the database. I would really appreciate.

    Good Work Mate!

  36. Rory says:

    This is a great series. Hopefully we’ll see more?
    Good work Burak!

  37. Cier says:

    Good tutorials but I prefer Jeffrey’s voice !

  38. Natrium says:

    I see you have Intellisense when typing, and autocomplete.
    Is that because you are working with a Project in Aptana?

  39. Thanks, great screencast.

    Are you from some Balkan country? You sound like you are :)

  40. Tom Van Assche says:

    Zomg! Thanks for starting this screencast again! :)

  41. Suciu Vlad says:

    Just a few tips:

    1. Instead of relying on javascript to check if it’s an ajax request you could just use this in the controller:
    if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) AND strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === ‘xmlhttprequest’))
    {
    //ajax request
    }

    2. instead of manually passing the values($(‘#name’).val()) you could save in a variable the serialized form.
    var data = $(‘form’).serialize();

    The array key passed back would be the name attribute of each input field.

    3. You don’t need to use php in javascript to have the url. Simply save in a variable the action attribute of the form.

    var url = $(‘form’).attr(‘action’)

    Regards.

    • Burak says:
      Author

      1. I read about this one recently. But I also saw someone mention that not all browsers may send this. I wanted to test it myself before starting to use it.

      2. and 3. Thanks for the tips. They are indeed useful shortcuts.

    • alex says:

      @2, could that also be used for CI
      $insert_data = array(
      ‘name’ => $this->input->post(‘firstname’),
      ‘lname’ => $this->input->post(‘lname’),
      etc.
      ).

      looking for a faster way to pass the vars from a form

  42. Great, I was looking forward to the next installment of the series.

  43. Kiraly Zoltan says:

    YEAH…Good work Burak,keep `em commin’ :)

  44. Javed Gardezi says:

    Finally after a loooooooooooooong time the series is back…
    I would like it to be completed as it was said in 1st tutorial

  45. Marcc says:

    Hey I’d like to see a tutorial on using self installed libraries, e.g. we could implement an authentication library and work with it.
    This would also cover my request of a more advanced login system, which supports email verification and different user profile pages.

    Keep up the good work…

  46. Tom says:

    Thanks for the tutorial, great work.

    Which PHP plugin do you use for Aptana?

  47. Man Mohan says:

    Is codeIgniter Support for custom plug-ins like ruby on rails does ?

    • Burak says:
      Author

      I am not familiar with RoR but CodeIgniter does support user created plug-ins. You can find a lot of them in the CI community and wiki pages.

  48. Adam says:

    Awesome screencast! So glad to see the CI series back in action.

    Jeffrey, could you possibly try to get CodeIgniter from Scratch days 2 & 5 into the iTunes feed?

    This is one series I would like to keep for future reference, but not all episodes of the series are available on iTunes…

    Can’t wait for more!

  49. Maik says:

    Thanks Burak for keep the codeigniter from scratch alive, It is great. Greetings from Mexico

Comment Page 1 of 21 2

Add a Comment

To add a code snippet to your comment, please wrap your code like so: <pre name="code" class="html">YOUR CODE</pre>. You can replace the class name with "js," "css," "sql," or "php." If there are any "<" or ">" within your code, please search and replace them with: &lt; and &gt; respectively.