5
我遇到了一个问题,挣扎了好几个小时。我使用jQuery负荷加载一个PHP网页,其中包含了tinyMCE其脚本(WordPress的)当我通过jQuery加载tinyMCE时,浏览器冻结.load()
$('.quickedit_form_' + parentID).load('<?php bloginfo('template_directory'); ?>/ajax/quickedit.php?id=' + parent.attr('id').replace('post-', ''), function(){
tinyMCE.init({
skin: 'wp_theme'
});
$.scrollTo(parent, 800, {offset: {left: 0, top: -61}});
});
而且我的PHP页面(quickedit.php)
<?php
// include WordPress
require('../../../../wp-blog-header.php');
// get post
global $current_user;
$id = $_GET['id'];
$post = get_post($id);
if ($current_user->ID != $post->post_author) {
wp_die(__('Unauthorized access.','sofa'));
}
?>
<h1 class="quickedit_h"><?php printf(__('Editing Post #%s','sofa'), $post->ID); ?></h1>
<label for="edit_title_<?php echo $id; ?>" class="quickedit_label"><?php _e('Title:','sofa'); ?></label>
<input type="text" name="edit_title_<?php echo $id; ?>" id="edit_title_<?php echo $id; ?>" value="<?php echo $post->post_title; ?>" class="quickedit_field" />
<label for="edit_type_<?php echo $id; ?>" class="quickedit_label"><?php _e('Post Type:','sofa'); ?></label>
<select name="edit_type_<?php echo $id; ?>" id="edit_type_<?php echo $id; ?>" class="quickedit_select">
<option value="text"<?php selected("text", sofa_post_type()); ?>><?php _e('Blog','sofa'); ?></option>
<option value="image"<?php selected("image", sofa_post_type()); ?>><?php _e('Image','sofa'); ?></option>
<option value="video"<?php selected("video", sofa_post_type()); ?>><?php _e('Video','sofa'); ?></option>
</select>
<div class="quickedit_save"><input type="button" value="<?php _e('Save','sofa'); ?>" class="button-secondary" /></div>
<?php
wp_editor($post->post_content, 'edit_content_'.$id, $settings = array(
'wpautop' => true,
'media_buttons' => true,
'textarea_name' => 'edit_content_'.$id,
'textarea_rows' => 10,
'tabindex' => '',
'editor_css' => '',
'editor_class' => 'edit_content',
'teeny' => false,
'dfw' => false,
'tinymce' => true,
'quicktags' => true
));
?>
<div class="quickedit_save"><input type="button" value="<?php _e('Save','sofa'); ?>" class="button-secondary" /></div>
<?php wp_footer(); ?>
当我quickload.php直接访问浏览器,一切都平稳,没有任何延迟或任何事情。但是,当我通过jQuery .load()访问它时,tinymce和按钮需要大约15秒才能加载,在Firefox和Chrome中尝试使用冻结浏览器(用户无法与任何内容交互)。
任何人都可以建议我为什么发生这种情况,一直小时,这个尝试.. :(
注:当我访问quickedit.php直接TinyMCE的加载罚款,并迅速崩溃/冻结发生在从jQuery的.load功能其称为
我需要的任何方向这可能是导致这个问题
我与.get()有相同的问题通过我的调试器,它为我加载jquery.min.ui.js文件时冻结 - 与asynch无关。它只会冻结/缓慢加载页面上的第一个.get()请求,随后的任何请求都会按预期进行响应。我认为这与我的代理服务器有关。 – elzaer 2012-10-18 01:36:00