Jquery ajax request works in some pages and in others it doesnt |
[eluser]iceuser[/eluser]
Code: $(".view_comments").click(function(){ HOw can the above ajax code work in some pages and it doesnt it wont work? This is just crazy! I have spent seriously HOURS trying to debug it by creating temp pages with just the neccessary html data needed to check if the request is the only problem but its not! It simply works on user homepage which is http://www.site.com/ and it wont work when a user views a message http://www.site.com/mssages/inbox/12313213 where the 1231313 is the ID of the message... The above is just for that ajax call some other work all the time and some others simply doesnt...
[eluser]vitoco[/eluser]
i can see 2 posible problems : 1.- click doesn't get called, cause "el.view_comments" are created dinamically Solution : use bind() or live() 2.- json response fails, and error event isn't defined Solution : add "error: function()" to ajax call and check server side Code: $(".view_comments").live( 'click' , function() Saludos
[eluser]iceuser[/eluser]
[quote author="vitoco" date="1340913665"]i can see 2 posible problems : 1.- click doesn't get called, cause "el.view_comments" are created dinamically Solution : use bind() or live() 2.- json response fails, and error event isn't defined Solution : add "error: function()" to ajax call and check server side Code: $(".view_comments").live( 'click' , function() Saludos[/quote] I am already using .live method so this doesnt seem to be the problem here... what happens is that i get the CLICKED message then the ajax request goes for 5-8 minutes and while i check it via Firebug i can see that the loading gif just spings for all the time without getting any error then finally after 5-8 minutes i see the red color with an "X" image next to the link and as response i get nothing i then get the ERROR message... The above request works on Safari(i am on an iMac) and on all browsers on Windows and other machines... it seems my iMac is the problem here... i even removed XAMPP as my web server and added MAMP which didnt fix the problem... next option is to clean install MAC OS X
[eluser]iceuser[/eluser]
If i change a bit the error function to: Code: error: function(jqXHR, textStatus, errorThrown) { i get: Code: ERROR
[eluser]vitoco[/eluser]
i think that you need to debug your server side script.
[eluser]iceuser[/eluser]
[quote author="vitoco" date="1340915019"]i think that you need to debug your server side script.[/quote] i have spent several hours debugging it client and server side but the problem seems to exist on Firefox and Chrome... as i explained above... It can't simply work for months and start going crazy for 2 browsers only and only on MAC! This is insane!!
[eluser]iceuser[/eluser]
[quote author="Matalina" date="1340918095"]how are you get www? for your url?[/quote] its a global variable in the javascript file located at the top... its outside Code: $(document).ready(function(){ });
[eluser]iceuser[/eluser]
[quote author="Matalina" date="1340918272"]and it's just a string?[/quote] yes its like Code: var www = "http://www.mysite.dev/"; which is a local host for my website development purposes |
Welcome Guest, Not a member yet? Register Sign In |