Posted by:
ashcanschool
(---.range31-51.btcentralplus.com)
Version of Operating system? - 64bit
Version of Wamp Server installed? - 64bit
Version of Apache you are running? - 2.4.9
Version of MySQL you are running? - 5.6.17
Version of PHP you are running? - 5.5.12
What colour is your WampManager icon? - Green
Do you have a HOSTS file? - Yes
I've set up a WAMP server to build and test a website. It's my first time and it's going swimmingly until I get to anything involving AJAX (jQuery based).
Basic start is a user login form. Submit button goes to JavaScript function which has an AJAX call within to check the database for user etc etc. This was failing. Google's Dev Tools were saying the issue was "unexpected token <" at line whatever. The line was when the AJAX returned.
Reading up this seems to be an issue when the AJAX is returning a blank html page "" which is not valid JavaScript and thus throws this error. And in this context I'm guessing it would throw this if say a 404 page was being throw up if the php could not be found.
So I crawled over that for an hour with no joy. Then I mocked up a simple version of the AJAX and ran that hoping to build the user login form again step by step to find my issue. That didn't work.
On a hunch I build the exact same thing on a real server (LAMP) and found that it did indeed work. So now I'm guessing that my issue has something to do with a WAMP server setup. I was led to believe that AJAX calls would just work from setup.
Any ideas of what might be causing this and where to go to look for info on how to setup WAMP correctly for jQuery and AJAX?
More obscure attempts involved swapping out:
[
localhost]
for
[
127.0.0.1]
which threw a "No 'Access-Control-Allow-Origin' header is present on the requested resource." error. I thought great Apache is on a different port. Nope Apache is on port 80.
Attempted to add in:
crossDomain: true;
dataType: "jsonp",
to the AJAX call and returned a: "Resource interpreted as Script but transferred with MIME type text/html" but this returned to the "unexpected token <" error.
I'm running out of ideas, so if you have any I'd be appreciative.