Welcome Guest, Not a member yet? Register   Sign In
basic ajax using CI
#11

[eluser]Randy Casburn[/eluser]
Ok then. As you present it, everything is perfect. No problems. Should work perfectly.

Randy
#12

[eluser]misterdonut[/eluser]
yes as i thought it should work properly

but the div is only displaying "Loading....";

its not showing "changed div".

no errors on firebug.

can you provide a simple example.
it would be very useful.
#13

[eluser]Randy Casburn[/eluser]
Again, it would have been helpful to know that you know how to use firebug before post #11.

You have the simplest example. You've confirmed your controller works. Your ajax request looks OK except for this: <?=base_url()?> which is stuck in the middle of a Javascript function. But I'm sure you've verified that is being 'translated' like the other one was.

If you want this to be simpler, hard code everything (urls, etc.).

So what shows up in the console of Firebug? Do you have [ Show XMLHttpRequests ] option turned on and is anything coming back from the server? If not, then your Ajax request is not making it to the server. That is likely the problem here.

Randy
#14

[eluser]misterdonut[/eluser]
thanks for the help randy.

i appreciated it so much.
found the error.

stupid me.
my browsing through localhost
and i have put my computer name as my base_url leading for not giving me output.

thank you so much
#15

[eluser]Randy Casburn[/eluser]
Great. Glad you got it worked out. Best of luck to you,

Randy
#16

[eluser]omgnoseat[/eluser]
I have a slightly different question. I already know how to fetch data with ajax, I just don't know whats the best way to pass it to the view.
I have the following situation:

Javascript->calls a controller function with ajax
controller -> calls model to retrieve database info
model-> passes data back to controller as an array
-> controller receives data, needs to send data to the view (without a page reload of course)

Now I could just format all the data in the controller and put the data inside a div using javascript. but that seems very sloppy.
Is there any good way for this? I'm handling quite large amounts of data (blog posts) and don't know how to effectivly handle this.

Thanks in advance
#17

[eluser]Randy Casburn[/eluser]
Wow! You really dug up an old one here.

Anyway, this is somewhat dependent on the person doing the coding. The purists will tell you to follow the MVC pattern precisely and others will tell you to optimize performance. The tradeoff comes in the maintainability of your code. The bottom line is you should code your system consistently.

I personally send the data directly out of the controller and bypass the view processing altogether. Others do it differently.

Randy
#18

[eluser]omgnoseat[/eluser]
[quote author="Randy Casburn" date="1277617945"]Wow! You really dug up an old one here.

Anyway, this is somewhat dependent on the person doing the coding. The purists will tell you to follow the MVC pattern precisely and others will tell you to optimize performance. The tradeoff comes in the maintainability of your code. The bottom line is you should code your system consistently.

I personally send the data directly out of the controller and bypass the view processing altogether. Others do it differently.

Randy[/quote]
Yep sorry haha. This was the only topic I could find that was similiar to my question. Thats what I used as a (temporarely) solution. Thanks for the reply Smile
If anyone else has a neater solution please notify us Smile




Theme © iAndrew 2016 - Forum software by © MyBB