Welcome Guest, Not a member yet? Register   Sign In
help with understanding ajax
#1

[eluser]Tom Taila[/eluser]
Hey, i use ci and jquery, and im about to start learning ajax, tbh its hard to find good tutorials but im still trying my best to learn, id like something to start me off though and i was wondering if anyone could help me get started on the understanding. lets say for example i wanted to process a login and check to see if its valid, if not an alert will come up saying "incorrect login details" and if the login validation passes then the login in form will turn into a "logOUT" button. In the background also the codeigniter code for setting all the user session data would be carried out also ofcourse.
im not asking for the exact code on how to do this i just thought this would be a good scenario to get me started, instead im just asking for the individual steps i would take to carry out such a thing, if someone wishes to throw some example code that would be a bonus to learn from so thanks Smile, cheers guys
#2

[eluser]Buso[/eluser]
- When there is an event like clicking on the login button (http://docs.jquery.com/Events), it triggers some javascript code
- In that code you put your ajax call, eg: $.post (http://docs.jquery.com/Ajax/jQuery.post#...llbacktype). This will send some data to the url specified.
- Your codeigniter controller receives that data, and sends some other data back to the browser, plus a 200 header status, which means everything is ok.
- The data is received back, and if there is a 200 header status, the callback function from your $.post function is executed. There you can do whatever you want, like checking if your controller said that the password is wrong, and make some fancy error msg appear.
#3

[eluser]LuckyFella73[/eluser]
Hi Tom,

in this thread I uploaded some code that should give you a good start.
The only thing you will have to add is a method that check the input
against user data from database (if login was correct) and what should
happen after the login was correct (redirect or whatever).

Just download the complete example here:
http://ellislab.com/forums/viewthread/15...15/#751212

It's a jquery/ json combination ..
#4

[eluser]Tom Taila[/eluser]
Hey guys, thankyou so much for your help, really helpful in understanding it for a noobie, this should definitly get the ball rolling for me, cheers, thanks again Tongue
#5

[eluser]pickupman[/eluser]
Tom,
A great book worth the read is jQuery in Action. It's pretty reasonable in paperback. I had used jQuery for awhile, but after reading the great examples made a lot more sense.
#6

[eluser]Tom Taila[/eluser]
really? a book would be perfect, ill order it today, thanks for the tip Smile
#7

[eluser]Tom Taila[/eluser]
Guys sorry this is a lil unrelated to the original question but im sure you'd know, just for future reference and to make sure i do my projects properly. I would like to know what order you guys would take it in to make a website from scratch. Would i be correct in saying that:

firstly create the graphical perception of it on photoshop and slice it up.
secondly html and css code it.
thirdly code igniter.
fourthly jquery and ajax.

or would the third and fourth positions be switched? or how would u guys do it?
#8

[eluser]pickupman[/eluser]
Depends on the skillset. Sometimes people work as the developer, and a client wants a prototype first. So, the html and css may come last. I would say js and ajax would come last, but plan for it in your code as you go. Name or give classes to elements you know will take js actions.

And I see [url="http://www.amazon.com/jQuery-Action-Second-Bear-Bibeault/dp/1935182323/ref=sr_1_1?ie=UTF8&s=books&qid=1275656668&sr=8-1"]jQuery in Action[/url] is in it's second edition for version 1.4 and I am a little jealous. The first edition is 1.2.6, but the only thing that really changed was that some of the popular plugins featured in the book, are now part of the core in 1.4.
#9

[eluser]LuckyFella73[/eluser]
Hi Tom,

I would say you are right with the first and a bit with the last point.

point 2 and 3 can't be seperated because the html and css part
is part of working with codeigniter too (controller/ view files).

The jquery/ajax should come at last because it's hard to paint
a chair that does not exist Wink

Working with ajax requires you to set up ci functions, in this way a part
of point 4 belongs to point 2+3
#10

[eluser]Tom Taila[/eluser]
hmm okay, thanks, ill probably start from scratch so i do everything rite from the start this time Smile


and pickupman, i found this http://www.4shared.com/get/43026990/65e0...5B0D.dc211




Theme © iAndrew 2016 - Forum software by © MyBB