HTTP 404 comes from the response header - there may be response content (usually the message "Oops, we cannot find it"), but it is ignored by some browsers if it is small (IE has its own messages for small 404s).
I assume the server adds an HTTP 404 status header to colorReset.php - this is PHP / any server you are using the problem on, not jQuery.
The jQuery $.get method only runs the success function if you return the HTTP 200 status from the server, otherwise it runs the error function, so you can still get your hex color code with the status 404.
Update
I think there is some kind of confusion.
- HTTP 404 does not mean that your browser cannot find the page
- HTTP 404 means that the server (in this case, Apache) tells you that it cannot find the page, but still returns a page with the content.
If you go to page 404 in your browser, it will just load the contents of the page.
If you load the 404 page via $.get , it will miss the assigned error method, but the constructor on $.get only allows you to set the success method.
Your jQuery will work if you do this:
var myImage = $('#theme :selected').text(); $.ajax({ url: '<?php echo get_bloginfo('template_directory') ?>/colorReset.php', data: {theme: myImage, spot: '1'}, success: function(data){doColor('#theme_header_color', data);}, error: function(data){doColor('#theme_header_color', data);} });
However, I would see why your server returns 404 first - colorReset.php may have an error or the server configuration may be incorrect.
Keith
source share