CodeIgniter from Scratch Day 8: AJAX
videos

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

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://www.nouveller.com/ Benjamin Reid

    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?

    • http://www.jeffrey-way.com Jeffrey Way

      Maybe, maybe not. Ever since I began managing CodeCanyon, I haven’t had much time left over. :( Don’t worry, Burak knows his stuff!

      • http://spotdex.com/ David Moreen

        Keep it up, Codecanyon kicks ass!

    • Khalil

      Thankyou Burak for CI Series…

      and We will be waiting for your tutorials Jeff.

    • http://www.enatom.com enatom

      NO MORE CODE IGNITOR TUTORIALS……..NO MORE CODE IGNITOR TUTORIALS……..NO MORE CODE IGNITOR TUTORIALS……..NO MORE CODE IGNITOR TUTORIALS……..NO MORE CODE IGNITOR TUTORIALS……..NO MORE CODE IGNITOR TUTORIALS……..NO MORE CODE IGNITOR TUTORIALS……..NO MORE CODE IGNITOR TUTORIALS……..NO MORE CODE IGNITOR TUTORIALS……..NO MORE CODE IGNITOR TUTORIALS……..NO MORE CODE IGNITOR TUTORIALS……..NO MORE CODE IGNITOR TUTORIALS……..NO MORE CODE IGNITOR TUTORIALS……..NO MORE CODE IGNITOR TUTORIALS……..

      PLEASE FFS!! get back to how it use to be.

      • http://www.phpandstuff.com Burak
        Author

        You misspelled CodeIgniter.

      • Brad

        Gee enatom, you could always change the channel. I cant get enough codeigniter tuts

      • Chris

        @enatom – Quite you! I’ve been waiting anxiously for this series to start back up!

      • vitesse

        @enatom – We are all happy but you…

      • Codeboi

        Shut up Enatom

      • Bretticus

        Thanks Burak for starting this back up. I love to refer forum patrons to these turorials. They are great. Watching yours right now.

  • Jamie

    Yay!

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

  • must

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

  • cem

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

    Nice tutorial.

    • http://www.phpandstuff.com Burak
      Author

      Teşekkürler.

      Thank you.

  • http://alejonanezortiz.blogspot.com/ Alejandro Ñañez

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

  • http://www.twitter.com/benoa Ben

    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!

    • http://www.phpandstuff.com Burak
      Author

      Hehe, codestar. I like that.

  • http://www.gold-price-today.com/ اسعار الذهب

    Great tutorials and good series for learning codeigniter
    thanks

  • Ben

    Oh hello welcome back!!

    Good to see them live on!

  • http://pixelcoder.co.uk Alistair

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

    Good work Burak, maybe liven it up a bit?

  • http://www.adiadi.info Adi

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

  • Vitesse

    OMG!!

    Please Burak don’t stop this series again…

    Thankyou!

  • http://adrusi.com Adrian

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

  • Kinsbane

    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.
    }

  • http://andrewburgess.posterous.com Andrew Burgess

    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

      Yes I vote for this great series…

      Please share Codeigniter + Doctrine Screencast Series…

      • Bretticus

        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.) :)

  • Hasn Ditri

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

    This is just horrible.

    • Hasn Ditri

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

      • http://www.phpandstuff.com Burak
        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”?

  • Rich

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

  • Brad

    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. :)

  • http://taylorhuthison.com Taylor Hutchison

    Loved this tutorial.

    The next codeigniter tutorial should be about Hooks or Security!

  • http://laranzjoe.blogspot.com lawrence77

    Burak has cold??

    Meanwhile a nice tut,

  • http://laranzjoe.blogspot.com lawrence77

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

    Nice RIP! Thanks :)

    • http://www.jeffrey-way.com Jeffrey Way

      Yeah – I thought the same thing. Burak, how did you get the file size so small?

      • http://www.phpandstuff.com Burak
        Author

        I didn’t do anything special. I just used the default quality setting in Camtasia, which is at 50%. The file size grows pretty fast when you increase it.

  • Chris

    Awesome!

  • Vukan

    What about tutorial for multi language site with database ? I

  • http://twitter.com/KGTheNerd Karthik

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

  • Mini0n

    A
    W
    S
    O
    M
    E

    Thanks! =D

  • arnold

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

    NO MORE CODE IGNITOR TUTORIALS
    @enatom , why?

    • http://www.nouveller.com/ Benjamin Reid

      He obviosuly thought it was opposites day.

      • Alex

        ha ha! ya I love these tutorials. Keep them going please!

  • Eric

    Great job Burak,

    CIfS will be safe in your hands.

  • Natrium

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

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

  • http://www.complimedia.com Montana Flynn

    Would love to see some cakePHP tuts as well!

  • aryan

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

  • Walter

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

  • PureLife Studio

    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.

  • Rime

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

  • http://www.woony.be woony

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

  • http://butenas.com Ignas

    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

      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.

    • http://www.phpandstuff.com Burak
      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

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

      • Walter

        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.

    • http://butenas.com Ignas

      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

      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.

  • Lacoasta

    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!

  • http://www.redkingdesigns.com Rory

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

  • Cier

    Good tutorials but I prefer Jeffrey’s voice !

  • Natrium

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

    • http://www.phpandstuff.com Burak
      Author

      Yes, Aptana has autocomplete features.

      • Klaus M.

        How can I set up Intellisense/Autocompletion for CodeIgniter in Aptana Studio 2.0 and what is your Color Setting in Aptana?
        Can you please explain this. Many thanks.

    • nachkata
  • http://tutsvalley.com Slobodan Kustrimovic

    Thanks, great screencast.

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

    • http://tutsvalley.com Slobodan Kustrimovic

      Ohh, just saw you’re from Turkey :) Greetings from Serbia :)

    • http://danijelblog.wordpress.com/ Danijel

      Greetings from Croatia too :)

    • http://www.phpandstuff.com Burak
      Author

      Greetings :)

  • Tom Van Assche

    Zomg! Thanks for starting this screencast again! :)

  • http://www.suciuvlad.com Suciu Vlad

    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.

    • http://www.phpandstuff.com Burak
      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

      @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

  • http://www.jordanwalker.net/index.php Jordan Walker

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

  • Kiraly Zoltan

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

  • Javed Gardezi

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

  • http://www.bloggerzbible.blogspot.com/ Bloggerzbible

    Really great work

  • Marcc

    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…

  • Tom

    Thanks for the tutorial, great work.

    Which PHP plugin do you use for Aptana?

  • http://mskhirwar.wordpress.com Man Mohan

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

    • http://www.phpandstuff.com Burak
      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.

  • Adam

    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!

  • http://www.maikdiaz.com Maik

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