jQuery ajax returning 404 error when passing URL as post data

Blake Plumb

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

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

jQuery ajax returning 404 error when passing URL as post data

From Dev

jQuery AJAX call returning 403 Forbidden error when passing Rgraph image data

From Dev

Jquery AJAX not passing "POST" data

From Dev

Jquery AJAX not passing "POST" data

From Dev

Laravel 5.3 : POST request using Ajax always returning Error 404 in console by jquery.min.js

From Dev

AJAX post not returning xml data in jQuery 1.9.1

From Dev

How to pass value from jquery ajax to servlet, I am facing 404 error while passing url

From Dev

Ajax JQuery Passing Data to POST method

From Dev

jQuery AJAX POST not passing data to a PHP script

From Dev

Jquery, Ajax Error 404 with Webmethod url

From Dev

Jquery Post is returning error instead of data

From Dev

Jquery ajax returning 404 not found

From Dev

Passing data with jquery ajax

From Dev

JavaScript jQuery AJAX POST data error

From Dev

Data not returning from ajax POST

From Dev

ASP MVC, jQuery issue returning error on ajax post when user hits enter key whilst textbox has focus

From Dev

Ajax post not passing data to php?

From Dev

Persistence of Redirect URL when redirecting after a POST and passing data

From Dev

Laravel Jquery Ajax 404 error and migration URL Issue

From Dev

Undefined parameter when returning data from jQuery.post to PHP

From Dev

When sending jQuery post to MVC controller getting 404 error

From Dev

passing data via ajax to php and returning

From Dev

JQuery ajax not working when passing ip address in data with parameters

From Dev

404 error when binding named function with jQuery ajax inside

From Dev

simple jquery .post not returning data

From Dev

jquery ajax call returning error

From Dev

JSP not returning data to JQuery AJAX

From Dev

JSP not returning data to JQuery AJAX

From Dev

Jquery Ajax function returning no data

Related Related

  1. 1

    jQuery ajax returning 404 error when passing URL as post data

  2. 2

    jQuery AJAX call returning 403 Forbidden error when passing Rgraph image data

  3. 3

    Jquery AJAX not passing "POST" data

  4. 4

    Jquery AJAX not passing "POST" data

  5. 5

    Laravel 5.3 : POST request using Ajax always returning Error 404 in console by jquery.min.js

  6. 6

    AJAX post not returning xml data in jQuery 1.9.1

  7. 7

    How to pass value from jquery ajax to servlet, I am facing 404 error while passing url

  8. 8

    Ajax JQuery Passing Data to POST method

  9. 9

    jQuery AJAX POST not passing data to a PHP script

  10. 10

    Jquery, Ajax Error 404 with Webmethod url

  11. 11

    Jquery Post is returning error instead of data

  12. 12

    Jquery ajax returning 404 not found

  13. 13

    Passing data with jquery ajax

  14. 14

    JavaScript jQuery AJAX POST data error

  15. 15

    Data not returning from ajax POST

  16. 16

    ASP MVC, jQuery issue returning error on ajax post when user hits enter key whilst textbox has focus

  17. 17

    Ajax post not passing data to php?

  18. 18

    Persistence of Redirect URL when redirecting after a POST and passing data

  19. 19

    Laravel Jquery Ajax 404 error and migration URL Issue

  20. 20

    Undefined parameter when returning data from jQuery.post to PHP

  21. 21

    When sending jQuery post to MVC controller getting 404 error

  22. 22

    passing data via ajax to php and returning

  23. 23

    JQuery ajax not working when passing ip address in data with parameters

  24. 24

    404 error when binding named function with jQuery ajax inside

  25. 25

    simple jquery .post not returning data

  26. 26

    jquery ajax call returning error

  27. 27

    JSP not returning data to JQuery AJAX

  28. 28

    JSP not returning data to JQuery AJAX

  29. 29

    Jquery Ajax function returning no data

HotTag

Archive