Welcome Guest, Not a member yet? Register   Sign In
JQuery and Ajax Issue

nvm - it checks if it's there and adds if not...

mate.. I've replicated your code on my machine and I had major problems with your declaration of the array variable in javascript. But works when you do it like this:
var series = new Array();

And I get Hello returned to content just fine.

Can't see how there would be a problem if i loaded it onto my web host.

How on earth did your var series{}; work in any location is beyond me..

I was using var series = {};

Thought that was short hand for initialising an array.

I have changed it like you said and now I receive a 404 on this function with the base url

<?php $base = base_url(); ?>
     var str = "";
     var url = "<?php echo $base . 'home/viewAll';?>";
     $('#houses').load( url, series, function(str){} );

And your version of the function does not trigger a Http request

function viewAll()

                    var base_url = "<?php echo base_url(); ?>";
                    var series = new Array();
                    var url = base_url + "home/viewAll";    
                    $("#houses").load( url, series, function(){} );

                    return false;

No... that's not what my version looks like... it's not a javascript function...

Inside your script should have something like this:
var base_url = "<?php echo $base_url; ?>";

$(document).ready(function() {

    $("a#view_all").click(function() {
        var series = new Array();
        series['id'] = 1;
        var url = base_url + "controller/controller_function";    
        $("#content").load( url, series, function(){} );

        return false;


Ok I just used your method exactly as shown and it works locally even though it seems rather slow, but still I get no response or error on the server. It is like JQuery is not attaching the event handler to the link as it still adds the hash to the URL?

You link should not be doing any on_click things right?

Should just be the link like i put in my prev example.

If it's not binding then is the link appearing through ajax as well? If so you will need to use it live.
$("a#view_all").live("click", function() {
// do your stuff here

well think im about back where i started, works fine locally with your code but on the server i just keep getting 404 not found. Thats for both relative and absolute urls. Do you think it could be my .htaccess messing it up?

Could be mate.. Try this one:

Don't forget to change the
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]

    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn't true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php?/$1 [L]

<IfModule !mod_rewrite.c>
    # If we don't have mod_rewrite installed, all 404's
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin

    ErrorDocument 404 /index.php

You need to change RewriteBase to your base url. EG:
Locally my base is http://localhost/sitename so rewritebase is "/site/"

On my web host it's just "/"

Nope same difference, I wonder what else could be wrong, I can not see the results of the controller method if i try to access the URL manually either. I still get the 404

Yet locally it works fine, and obviously I know it exists

Your server probably doesn't like you using htaccess - you will need to turn it on somehow... google it... prove this by putting in index.php/controller/function

Theme © iAndrew 2016 - Forum software by © MyBB