JQuery AJAX to PHP issue with CORS -


i trying build php api can use jquery post in order make phonegap app. keep running problem cors (i think) when try use ajax call

here ajax call:

$.ajax({     type: 'post',     url: "http://xxx.xxx.xxx.xxx/v1/login",     data: {          user: username,          pass: password     } }).done(function( msg ) {     console.log(msg); }); 

and here headers i'm setting in php file:

header('access-control-allow-origin: *'); header('access-control-allow-methods: get, post, put, delete, options'); header('access-control-max-age: 604800'); header('access-control-allow-headers: x-requested-with'); 

every time run ajax call same errors returned in console:

post http://xxx.xxx.xxx.xxx/v1/login 500 (internal server error)  l.cors.a.crossdomain.send o.extend.ajax login onclick 

the ajax call inside function called 'login' being run on button click, think accounts last 2 lines of error message, don't understand rest. also, if add contenttype: "application/json" ajax call error message changes

options http://xxx.xxx.xxx.xxx/v1/login 500 (internal server error) l.cors.a.crossdomain.send o.extend.ajax login onclick xmlhttprequest cannot load http://xxx.xxx.xxx.xxx/v1/login. invalid http status code 500  

i don't know if matters, i'm running on aws ec2 running amazon linux , lamp stack set following these instructions: http://docs.aws.amazon.com/awsec2/latest/userguide/install-lamp.html

the remaining hair havn't pulled out yet says can give. :)

i don't think related cors. status code 500 means wrong in server. check server logs error.


Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -