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

#11
[eluser]alboyd[/eluser]
As far as I know this is the way most people do it. But I might be wrong! Hopefully some regulars will chime in...

It's an easy way to do it and it works perfectly and gives you heaps of flexibility so why not!

#12
[eluser]Bendude[/eluser]
Ok I went the same way as you suggested with a main_view and passing in variables with the view names to be loaded and I think it seems much cleaner. All is working locally but for some reason I get no response from the server when I upload it. Using firebug i can see the data been sent via POST but no response.


Can you suggest any techniques / tools to track the issue down.

I have simplified my function to I am simply sending an Ajax request and the response is just echo "Hello" but i still receive nothing.

I also changed my links to relative links but this did not help either.

Regards
Ben

#13
[eluser]alboyd[/eluser]
It's hard to troubleshoot when uploaded. I use full paths in every single area (Jquery, views etc).

In my example you will see i have base_url + "controller..." - base_url is defined at top of the view using php.

I'd just check that you use full paths all the way.. so much simpler than messing around with relative paths. No other ideas for you really..

EDIT: Add some alerts maybe? then upload again and see what you can debug that way?

#14
[eluser]Bendude[/eluser]
im using base_url() where i can but relative links to the method names from within javascript.

I just changed this line in my config file

$config['uri_protocol'] = "REQUEST_URI";

and a few other things have started working, so will see if this helps at all...

#15
[eluser]alboyd[/eluser]
I always use AUTO - never had a problem with AJAX. Are you using JQuery?

Put in a base_url for your Javascript too I would recommend.

Code:
<!--
    var base_url = "<?php echo $base_url; ?>";
//-->

#16
[eluser]Bendude[/eluser]
with altering the uri_protocol setting i was unable to view any of my other controllers.

Now when i use relative urls from within my javascript to my controller functions i got 404 not found in firebug and if i use the baseurl a Http Request never occurs and neither firefox or firebug report an error.

#17
[eluser]alboyd[/eluser]
mmm sounds like things are a little screwed up mate.. Did you change your $config['base_url'] setting? have you removed index.php? ( not that that matters just interested )

#18
[eluser]Bendude[/eluser]
yes i have a fully working application locally and nothing working at all remote. changed the base_url setting, and I have not removed the index.php page.

#19
[eluser]alboyd[/eluser]
Are you using JQuery for your Javascript and Ajax?

Maybe try and post your controller, ajax request and config settings?

#20
[eluser]Bendude[/eluser]
Yes for this part I am using JQuery, I wrote all the Ajax code manually in the back end so I had more control and because I am unfamiliar with JQuery. But I thought for the front end I would use some of JQuerys effects and It would also be more simple for what I needed.

On the front page I have a
Code:
<a href="[removed]viewAll()">Test</a>

my javascript method looks like this
I have used both absolute and relative URL's on the server I can not get a relative URL to give me
a response other than Not Found. The absolute URL gives no response at all in firebug. No request is made
Code:
function viewAll()
{
    var series{};
    series['id'] = 1;
    var url = "/controller/viewAll";    
    $('#content').load( url, series, function(){} );
}

Then the controller looks like this
Code:
function viewAll()
{
    echo "hello";
}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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