• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
JQuery and Ajax Issue

#21
[eluser]alboyd[/eluser]
I would do it like this:

In View:
Code:
[removed]

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

[removed]

...
...

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

Then in the Javascript script section or included file:
Code:
$("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']

#22
[eluser]Bendude[/eluser]
Unfortunately your code produces the exact same result.

Thanks for all the help though...

#23
[eluser]Unknown[/eluser]
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...........

#24
[eluser]alboyd[/eluser]
[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?

#25
[eluser]Bendude[/eluser]
Sure did, I knew base_url has a slash at the end.

#26
[eluser]alboyd[/eluser]
I edited my above post...

#27
[eluser]Bendude[/eluser]
yes i have the script tags

yes the base url is getting to the view

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

#28
[eluser]alboyd[/eluser]
Where is your index.php? Thought you were still using it?

#29
[eluser]alboyd[/eluser]
Also get rid of the trailing / in the base_url - it gets added automatically I think when you retrieve base_url...

#30
[eluser]Bendude[/eluser]
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]


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.