Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] getting jquery to do ajax
#1

[eluser]runs.amock[/eluser]
hi

i am trying to replace a div Id (called ajax_area)
with a controller call (with view) to HOMES/INDEX,
when an area on the screen is clicked.

jquery is loading.
localhost/homes/index is working.

Here is the js code I use to make the call.

Code:
$(document).ready(function() {                    
    $("#models").click(function(){  
          $('#ajax_area').html("<?= site_url('/homes/index') ?>");
    });
});

It just replaces the div area with the letters: LOCALHOST/HOMES/INDEX.
I replaced .html with .load, and then the screen stay's black.
Is there something else I am missing?

Thanks...
#2

[eluser]runs.amock[/eluser]
SOLVED.

On Ubuntu with XAMPP, I had to have the div id declared in the css file, for this ajax call to work. Then, this worked:

Code:
$('#ajax_area').load("/homes");

That took 6 hours to figure out.
#3

[eluser]InsiteFX[/eluser]
Any element that you want to use with jQuery should be defined in your CSS file.

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB