I'm using this jQuery below call to load a .php file located on the same server.
However, using Chrome's javascript console, its reporting "404 not found" on the php file I'm trying to load. Although, I can load the file directly, just by clicking on the file right there from within the console.
Also, I can copy the URL of the file, right from the javascript console where it reports 404 (not found), open a new tab, paste it into the address bar, and hit the script fine, without issue.
Is this something specific to the jQuery get method? What could be causing the page to 404 in the get method but execute fine when called directly?
$('.colorReset').click
(
function()
{
var myImage = $('#theme :selected').text();
$.get('<?php echo get_bloginfo('template_directory') ?>/colorReset.php', {theme: myImage, spot: '1'}, function(data){doColor('#theme_header_color', data);});
}
);
//script never gets to the doColor function, due to the apparent 404 on colorReset.php
function doColor(el, color)
{
$(el).val(color).trigger('keyup');
$(el).attr('value', color);
$(el).val(color);
}
Here is the source file, colorReset.php, that's called by the get...
<?php
require_once('../../../wp-blog-header.php');
add_action( 'admin_init', 'check_user' );
function check_user()
{
if (!is_user_logged_in()){
die("You Must Be Logged In to Access This");
}
if( ! current_user_can('edit_files')) {
die("Oops sorry you are not authorized to do this");
}
}
$myTheme = $_REQUEST['theme'];
$spot = $_REQUEST['spot'];
$myThemeColor = $myTheme."_color".$spot;
$file = "styles/".$myTheme."/template.ini";
if (file_exists($file) && is_readable($file))
{
$ini_array = parse_ini_file($file);
if($spot == 1){$myColor = $ini_array['color1'];}
if($spot == 2){$myColor = $ini_array['color2'];}
if($spot == 3){$myColor = $ini_array['color3'];}
if($spot == 4){$myColor = $ini_array['color4'];}
}
else
{
if($spot == 1){$myColor = get_option('theme_header_color');}
if($spot == 2){$myColor = get_option('theme_sidebar_color');}
if($spot == 3){$myColor = get_option('theme_spot_color_alt');}
if($spot == 4){$myColor = get_option('theme_spot_color_alt2');}
}
echo $myColor;
?>