jQuery ajax returning 404 error when passing URL a

2019-07-21 15:02发布

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();

1条回答
虎瘦雄心在
2楼-- · 2019-07-21 15:51

I think it is server response. Server try to prevent cross-domain attack. What is in server logs? What is the server?

查看更多
登录 后发表回答