AJAX on Localhost not working for GET requests
Posted by: Mokonzi (---.54.23.190.res.adsl.dyn.click.com.py)
Date: June 03, 2012 05:06PM

I've got the version 2.2 of Wampserver installed, and all is working well, except for GET requests in Javascript/AJAX calls.

Most Javascript works normally, but I've noticed that when I request a reload of a portion of the page it ignores the AJAX load, and instead loads the page completely. I've searched for similar, and it was suggested it might be the setup of PHP and Apache preventing it, but so far the various things I've tried aren't working.

What could be the likely reason Wampserver wouldn't allow the GET AJAX requests? I'm, running Wampserver on Windows 7.

Thanks in advance for the help.

Mokonzi

Mokonzi

Options: ReplyQuote
Re: AJAX on Localhost not working for GET requests
Posted by: stevenmartin99 (Moderator)
Date: June 03, 2012 05:17PM

its most likely your code

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: AJAX on Localhost not working for GET requests
Posted by: Mokonzi (---.54.23.190.res.adsl.dyn.click.com.py)
Date: June 03, 2012 05:20PM

I've got the same code working on a live server without any issues, it's just on my local install that I've got the problem.

Mokonzi

Options: ReplyQuote
Re: AJAX on Localhost not working for GET requests
Posted by: stevenmartin99 (Moderator)
Date: June 03, 2012 05:22PM

that doesnt mean much to be honest...

can you paste the code? as small a piece as possible that still has an error.

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: AJAX on Localhost not working for GET requests
Posted by: Mokonzi (---.54.23.190.res.adsl.dyn.click.com.py)
Date: June 03, 2012 05:24PM

I'll post the code, but two very experienced Javascript developers have already looked over the code and concluded the problem is more likely with the server setup.

$.noConflict(true)(function($)
{
//store all tabs and forum part for reuse
var tabs = $('#content dl.tabslight dd'),
forums = $('#forums'),
cachedForums = {},
clickedTab = '';

// when a tab link is clicked...
$('a', tabs).click(function(e)
{
// stop the browser from acting on the click
e.preventDefault();

//load the a obj into jquery obj
var self = $(this);

//only mark the tab clicked as active
tabs.removeClass('selected');
self.parent().addClass('selected');

if (typeof cachedForums[self.attr('href')] == 'undefined')
{
// Store this
clickedTab = self.attr('href');

// load the link, extract the forums, replace on page
forums.load(clickedTab + ' #forums', {}, function(data)
{
// Cache the resulting HTML
cachedForums[clickedTab] = forums.html();
clickedTab = '';
});
}
else
{
// Use cached data
forums.html(cachedForums[self.attr('href')]);
}
});

$('body').on(
{
ajaxStart: function()
{
$(this).addClass('loading');
},
ajaxStop: function()
{
$(this).removeClass('loading');
}
});

$('a.handle').click(function(e) { e.preventDefault();
$('#mymenu').toggle('slow', function() {

});
});
});

Mokonzi

Options: ReplyQuote
Re: AJAX on Localhost not working for GET requests
Posted by: stevenmartin99 (Moderator)
Date: June 03, 2012 05:48PM

yes but there isnt anything WRONG with the server setup.

Im not sure how they would think that. It has nothing to do with PHP. and since wamp is downloaded 15,000 times a day , its unlikely your the first to find a bug of such broad scope.

secondly i have AJAX get requests working just fine.


this code isnt enough, all the functions for the actually http requests are not here.

What browser are you using? have you tried others?
Are you using localhost in the URL or you have set up vhosts?

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]



Edited 1 time(s). Last edit at 06/03/2012 05:48PM by stevenmartin99.

Options: ReplyQuote
Re: AJAX on Localhost not working for GET requests
Posted by: Mokonzi (---.54.23.190.res.adsl.dyn.click.com.py)
Date: June 03, 2012 06:13PM

The script works out of jQuery which is loaded from the google apis site.

I have vhosts setup to redirect a domain to my local host. I have tried Chrome and Firefox and as said before it works on a live site with both browsers.

I didn't imply that wampserver was broken. Rather that my install was somehow incorrect. I have found other cases where there have been issues with localhost installs and AJAX. Trying those hasn't fixed it which is why I've come here for advice.

Mokonzi

Options: ReplyQuote
Re: AJAX on Localhost not working for GET requests
Posted by: dannel (123.171.218.---)
Date: June 07, 2012 01:52AM

eh…… now i have the same problem 2....
i do not understand 2
i got a piece of code from [www.w3schools.com]
I've got the same code working on a live linux server without any issues, it's just on my local install that I've got the problem.

any answers……?

Options: ReplyQuote
Re: AJAX on Localhost not working for GET requests
Posted by: stevenmartin99 (Moderator)
Date: June 07, 2012 08:32AM

Can one of you get Teamviewer and I'll check it because there is nothing that is part of wamP that is set to stop it working

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: AJAX on Localhost not working for GET requests
Posted by: Mokonzi (---.telecel.com.py)
Date: June 07, 2012 04:30PM

I will have a look at this when I get back home this weekend and post the result here.

Mokonzi

Options: ReplyQuote
Re: AJAX on Localhost not working for GET requests
Posted by: dannel (111.14.108.---)
Date: June 12, 2012 02:54PM

ano....
is it ok now i can't wait to know....

Options: ReplyQuote
Re: AJAX on Localhost not working for GET requests
Posted by: Mokonzi (---.oxfd.adsl.virginmedia.com)
Date: June 12, 2012 05:41PM

Steven was looking into something last I heard which was on Saturday. We tried a few things and weren't able to find a fix. Steven will have a better idea of things.

Mokonzi

Options: ReplyQuote


Sorry, only registered users may post in this forum.