[wp-trac] [WordPress Trac] #27536: AJAX call returns all page errors along with plugin's response
WordPress Trac
noreply at wordpress.org
Thu Mar 27 00:39:56 UTC 2014
#27536: AJAX call returns all page errors along with plugin's response
------------------------------+-------------------------
Reporter: Justin Folvarcik | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: General | Version: 3.8.1
Severity: normal | Resolution: invalid
Keywords: | Focuses: javascript
------------------------------+-------------------------
Description changed by SergeyBiryukov:
Old description:
> I'm working on a plugin which uses AJAX to get the titles of a page from
> a user-given URL. Everything works fine... until I get to the server's
> response.
> {{{
> function t3_set_handlers(){
> var input = jQuery('[id^=post-source], [id^=post-via]');
> input.each(function(){
> jQuery(this).on('change', function(){
>
> var data = {
> action:'t3_get_url_title',
> url:jQuery(this).val()
> };
> var currentbox = jQuery(this);
> jQuery.post(ajaxurl, data, function(response, status, xhr){
> xhr.done(function(){
> console.log(response);
> //var name = jQuery().attribute('id').split('-');
> //jQuery('#post-'+name[1]+'-title-'+name[2]).val(title);
> }).fail(function(){
> // Something went wrong, so we'll turn off the AJAX
> and let the user know.
> alert('AJAX error encountered! Failed to retrieve
> title. If this problem persists, please send an' +
> 'email to justin at zeldawiki.org describing the
> issue.');
> input.off();
> });
> });
> });
> });
> }
> jQuery(t3_set_handlers());
> }}}
>
> In this code, the response variable should contain what the server sent
> back (IE: my current debug value, a JSON type string which is simply
> { "name":"value" }
>
> However, this is what I'm seeing in my console right now.
> <br />
> <b>Warning</b>: copy(/var/www/html/temple3/wp-content/ewww/jpegtran):
> failed to open stream: Permission denied in <b>/var/www/html/temple3/wp-
> content/plugins/ewww-image-optimizer/ewww-image-optimizer.php</b> on line
> <b>753</b><br />
> <br />
> <b>Warning</b>: copy(/var/www/html/temple3/wp-content/ewww/jpegtran-
> custom): failed to open stream: Permission denied in
> <b>/var/www/html/temple3/wp-content/plugins/ewww-image-optimizer/ewww-
> image-optimizer.php</b> on line <b>766</b><br />
> <br />
> <b>Warning</b>: fileperms(): stat failed for /var/www/html/temple3/wp-
> content/ewww/jpegtran-custom in <b>/var/www/html/temple3/wp-
> content/plugins/ewww-image-optimizer/ewww-image-optimizer.php</b> on line
> <b>770</b><br />
> <br />
> <b>Warning</b>: chmod(): No such file or directory in
> <b>/var/www/html/temple3/wp-content/plugins/ewww-image-optimizer/ewww-
> image-optimizer.php</b> on line <b>773</b><br />
> <br />
> <b>Warning</b>: copy(/var/www/html/temple3/wp-content/ewww/gifsicle):
> failed to open stream: Permission denied in <b>/var/www/html/temple3/wp-
> content/plugins/ewww-image-optimizer/ewww-image-optimizer.php</b> on line
> <b>787</b><br />
> <br />
> <b>Warning</b>: copy(/var/www/html/temple3/wp-content/ewww/optipng):
> failed to open stream: Permission denied in <b>/var/www/html/temple3/wp-
> content/plugins/ewww-image-optimizer/ewww-image-optimizer.php</b> on line
> <b>800</b><br />
> <br />
> <b>Warning</b>: copy(/var/www/html/temple3/wp-content/ewww/pngquant):
> failed to open stream: Permission denied in <b>/var/www/html/temple3/wp-
> content/plugins/ewww-image-optimizer/ewww-image-optimizer.php</b> on line
> <b>813</b><br />
> <div id='ewww-image-optimizer-warning-tool-install'
> class='error'><p><strong>EWWW Image Optimizer could not install tools in
> /var/www/html/temple3/wp-content/ewww/.</strong> Please adjust
> permissions or create the folder. If you have installed the tools
> elsewhere on your system, check the option to Use System Paths. For more
> details, visit the <a href='options-general.php?page=ewww-image-optimizer
> /ewww-image-optimizer.php'>Settings Page</a> or the <a
> href='http://wordpress.org/extend/plugins/ewww-image-
> optimizer/installation/'>Installation
> Instructions</a>.</p></div>.{"name":"value"}
>
> I'm not saying these errors are bugs. I know what they're from, but what
> I do NOT understand is why these are being outputted along with my
> response. According to all the documentation I've seen and the other
> people I've spoken with, my code is correct. I'll even provide the PHP:
>
> {{{
> function t3_get_url_title(){
> if(is_admin()){
> echo json_encode(array('name' => 'value'));
> die();
> }
> }
> }}}
>
> The only logical reason I can come up with for this is that WordPress is
> doing something it shouldn't be. Or maybe everything I've heard and read
> is wrong and you can tell me why. I am submitting this as a bug report
> because I truly believe this is a bug. I have spoken with other
> developers, checked my code against the documentation and even other,
> working code examples. My syntax should be correct.
>
> I would appreciate it if either this issue could be investigated or
> someone can tell me why I'm stupid and can't get this to work. Thanks in
> advance.
New description:
I'm working on a plugin which uses AJAX to get the titles of a page from a
user-given URL. Everything works fine... until I get to the server's
response.
{{{
function t3_set_handlers(){
var input = jQuery('[id^=post-source], [id^=post-via]');
input.each(function(){
jQuery(this).on('change', function(){
var data = {
action:'t3_get_url_title',
url:jQuery(this).val()
};
var currentbox = jQuery(this);
jQuery.post(ajaxurl, data, function(response, status, xhr){
xhr.done(function(){
console.log(response);
//var name = jQuery().attribute('id').split('-');
//jQuery('#post-'+name[1]+'-title-'+name[2]).val(title);
}).fail(function(){
// Something went wrong, so we'll turn off the AJAX
and let the user know.
alert('AJAX error encountered! Failed to retrieve
title. If this problem persists, please send an' +
'email to justin at zeldawiki.org describing the
issue.');
input.off();
});
});
});
});
}
jQuery(t3_set_handlers());
}}}
In this code, the response variable should contain what the server sent
back (IE: my current debug value, a JSON type string which is simply
{{{
{ "name":"value" }
}}}
However, this is what I'm seeing in my console right now.
{{{
<br />
<b>Warning</b>: copy(/var/www/html/temple3/wp-content/ewww/jpegtran):
failed to open stream: Permission denied in <b>/var/www/html/temple3/wp-
content/plugins/ewww-image-optimizer/ewww-image-optimizer.php</b> on line
<b>753</b><br />
<br />
<b>Warning</b>: copy(/var/www/html/temple3/wp-content/ewww/jpegtran-
custom): failed to open stream: Permission denied in
<b>/var/www/html/temple3/wp-content/plugins/ewww-image-optimizer/ewww-
image-optimizer.php</b> on line <b>766</b><br />
<br />
<b>Warning</b>: fileperms(): stat failed for /var/www/html/temple3/wp-
content/ewww/jpegtran-custom in <b>/var/www/html/temple3/wp-
content/plugins/ewww-image-optimizer/ewww-image-optimizer.php</b> on line
<b>770</b><br />
<br />
<b>Warning</b>: chmod(): No such file or directory in
<b>/var/www/html/temple3/wp-content/plugins/ewww-image-optimizer/ewww-
image-optimizer.php</b> on line <b>773</b><br />
<br />
<b>Warning</b>: copy(/var/www/html/temple3/wp-content/ewww/gifsicle):
failed to open stream: Permission denied in <b>/var/www/html/temple3/wp-
content/plugins/ewww-image-optimizer/ewww-image-optimizer.php</b> on line
<b>787</b><br />
<br />
<b>Warning</b>: copy(/var/www/html/temple3/wp-content/ewww/optipng):
failed to open stream: Permission denied in <b>/var/www/html/temple3/wp-
content/plugins/ewww-image-optimizer/ewww-image-optimizer.php</b> on line
<b>800</b><br />
<br />
<b>Warning</b>: copy(/var/www/html/temple3/wp-content/ewww/pngquant):
failed to open stream: Permission denied in <b>/var/www/html/temple3/wp-
content/plugins/ewww-image-optimizer/ewww-image-optimizer.php</b> on line
<b>813</b><br />
<div id='ewww-image-optimizer-warning-tool-install'
class='error'><p><strong>EWWW Image Optimizer could not install tools in
/var/www/html/temple3/wp-content/ewww/.</strong> Please adjust permissions
or create the folder. If you have installed the tools elsewhere on your
system, check the option to Use System Paths. For more details, visit the
<a href='options-general.php?page=ewww-image-optimizer/ewww-image-
optimizer.php'>Settings Page</a> or the <a
href='http://wordpress.org/extend/plugins/ewww-image-
optimizer/installation/'>Installation
Instructions</a>.</p></div>.{"name":"value"}
}}}
I'm not saying these errors are bugs. I know what they're from, but what I
do NOT understand is why these are being outputted along with my response.
According to all the documentation I've seen and the other people I've
spoken with, my code is correct. I'll even provide the PHP:
{{{
function t3_get_url_title(){
if(is_admin()){
echo json_encode(array('name' => 'value'));
die();
}
}
}}}
The only logical reason I can come up with for this is that WordPress is
doing something it shouldn't be. Or maybe everything I've heard and read
is wrong and you can tell me why. I am submitting this as a bug report
because I truly believe this is a bug. I have spoken with other
developers, checked my code against the documentation and even other,
working code examples. My syntax should be correct.
I would appreciate it if either this issue could be investigated or
someone can tell me why I'm stupid and can't get this to work. Thanks in
advance.
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/27536#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list