Freezing browser when loading tinyMCE via jQuery.load ()

I am facing a problem struggling for hours. I use jQuery download to load a php page that contains tinyMCE and its scripts (wordpress)

    $('.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}});
    });

And my php page (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(); ?>

When I access quickload.php directly in the browser, everything loads smoothly, without delay or something else. But when I access it through jQuery.load (), tinymce and buttons take about 15 seconds to load, freezing the browser (the user cannot interact with anything), both in Firefox and in Chrome.

Can anyone suggest to me why this happens, spent hours trying with this .. :(

: quickedit.php, tinymce . / , jquery.load.

- , ?

+5
1

jQuery ajax: jQuery.ajax

jQuery(function($) {
  var ajax_url = '<?php bloginfo('template_directory'); ?>/ajax/quickedit.php?id=' + parent.attr('id').replace('post-', ''); //Included for readability
  //Check if the elem is in the DOM, if so, load it via AJAX
  if ($('.quickedit_form_' + parentID).length >0) {
    $.ajax({ 
       url: ajax_url
       complete: function  () {
          tinyMCE.init({ 
          skin: 'wp_theme'
          });
         $.scrollTo(parent, 800, {offset: {left: 0, top: -61}});
       }
    });
  }
});

, , jQuery.load(, , ...?) () .

0

All Articles