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

I would do it like this:

In View:

var base_url = "<?php echo $base_url; ?>";



<a href="#" id="view_all">Test</a>

Then in the Javascript script section or included file:
$("a#view_all").click(function() {
    var series{};
    series['id'] = 1;
    var url = base_url + "controller/viewAll";    
    $("#content").load( url, series, function(){} );

    return false;

And your controller function can stay the same. try that and let me know...

EDIT: [removed] should be the open and close tags of javascript script
EDITEDIT: obviously $base_url is passed to the view and is basically base_url(); which I guess you could also use in the view rather than the variable... Smile

LASTLY: show me your $config['base_url']

Unfortunately your code produces the exact same result.

Thanks for all the help though...

Thank your for sharing this wonderful story. I find your post very informative.
I am very excited to be a part of this Forum and look forward to bringing Value to it...........

[quote author="Bendude" date="1260450782"]Unfortunately your code produces the exact same result.

Thanks for all the help though...[/quote]

Did you change the leading forward slash in the controller call in the ajax request?

EDIT: Have you tried putting the url you see in your "view source" directly into your address bar and see if you get the result returned "Hello".

Try using .post instead?

Sure did, I knew base_url has a slash at the end.

I edited my above post...

yes i have the script tags

yes the base url is getting to the view

$config['base_url'] = "http://domainname.com.au/";

Where is your index.php? Thought you were still using it?

Also get rid of the trailing / in the base_url - it gets added automatically I think when you retrieve base_url...

sorry I thought you was on about the actual index file

i have this setting

$config['index_page'] = "";

and this in my .htaccess

Options +FollowSymLinks
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|files|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]

Theme © iAndrew 2016 - Forum software by © MyBB