I have been getting a 404 error when using $.ajax
and have narrowed it down to the problem being with one of the values I am passing with data.
I am trying to pass a url as text to be saved to my database.
$.ajax({
type: 'POST',
url: 'ajax.php',
data: {'edit-username': username, 'website-value': websiteValue}
}).done(function(){
//custom code here
});
If I set websiteValue
equal to http://google.com, Then I get a 404 error on chromes network tab. (this is true for anything other than my own domain.)
If I set it to //google.com or just google.com it works fine.
If I set it to http://mydomain.com it also works great.
I can't figure this one out and any help would be greatly appreciated. The ajax calls are being done over https if that makes any difference.
The ajax.php file does the following with the data.
$mysqli = connect_db();
$query = $mysqli->prepare('UPDATE tbl SET website = ? WHERE username = ?');
$query->bind_param('ss', $website, $username);
$query->execute();
$query->close();
$mysqli->close();