JQuery AJAX Simple PHP Post Not Working
I have a very simple one today! I am trying to post a message from jQuery to a PHP file hosted on localhost.
My JS:
$("#searchNameButton").click(function() {
var name = $("#searchNameText").val();
$.ajax({
type: 'POST',
url: 'localhost:8080/getNameInfo.php', // -> this works fine from the browser
// data: { name: name }, -> commented out
success: function(){
alert('request successful');
},
error: function(xhr, textStatus, errorThrown){
alert('request failed');
}
})
});
My PHP file (getNameInfo.php), very simple to test:
<?php
echo 'TEST';
?>
In jQuery, it always gives me an error saying "Internal Server Error". I am using Ripple Emulator and this is what appears in the console:
POST https://rippleapi.herokuapp.com/xhr_proxy?tinyhippos_apikey=ABC&tinyhippos_rurl=localhost%3A8080/getNameInfo.php 500 (Internal Server Error)
I guess he should be doing more with it than with what is written in the files. Any advice? Thank!
EDIT: Found the following: LINK , but it won't affect my problem. If I do what it says here, I don't get any error ("" instead of), but it still doesn't work.
EDIT 2: If I set the cross domain proxy to the local one in Ripple (which is listed in the link above), I get
OPTIONS http: // localhost: 4400 / ripple / xhr_proxy? Tinyhippos_apikey = ABC & tinyhippos_rurl = http% 3A // localhost% 3A8080 / getNameInfo.php net :: ERR_CONNECTION_REFUSED
EDIT 3 : changed my url to local
C: //Mobile//Cross-Platform//TestApp//www//php//getNameInfo.php
and now it works. Not sure how to get it to work on localhost. BUt will go with this now as this is a tutorial app only.
source to share