小编Rob*_*ert的帖子

我如何使用jQuery重定向?

我使用HTML表单提交到jQuery验证,然后通过ajax将信息发送到PHP处理页面.

当一切都恢复正常时,一切都工作100%我无法让页面重定向到成功页面.

我的代码是:

$.post(url,{ username: value_login.val(), firstname: value_firstname.val(), lastname: value_lastname.val(), email: value_email.val(), password: value_password.val()} , function(data) {

    if(data == 'success'){

        window.location.href = "http://example.com/Registration/Success/";
    } else {
       $('#error').text('error');
    }

});
Run Code Online (Sandbox Code Playgroud)

我想你不能使用该window.location.href功能重定向.

javascript jquery

18
推荐指数
2
解决办法
12万
查看次数

Tinymce中的Shortcode下拉框在WordPress 3.9中不起作用?

嗨,因为新版本即将发布我想我会下载它,看看我的主题是否仍然有用.

除了现在更长时间显示的下拉框之外,一切都很好.

以下是我们在以前版本中用于显示的代码.

PHP代码:

function register_ppp_shortcodes( $buttons ) {
   array_unshift( $buttons, "Shortcodes" );
   return $buttons;
}

function add_ppp_shortcodes( $plugin_array ) {
   $plugin_array['Shortcodes'] = get_template_directory_uri() . '/js/Shortcodes_js.js';
   return $plugin_array;
}

function ppp_shortcodes() {

   if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages') ) {
      return;
   }

   if ( get_user_option('rich_editing') == 'true' ) {
      add_filter( 'mce_external_plugins', 'add_ppp_shortcodes' );
      add_filter( 'mce_buttons', 'register_ppp_shortcodes' );
   }

}

add_action('init', 'ppp_shortcodes');
Run Code Online (Sandbox Code Playgroud)

JS代码:

/*global tinyMCE, tinymce*/
/*jshint forin:true, noarg:true, noempty:true, eqeqeq:true, bitwise:true, strict:true, undef:true, unused:true, curly:true, browser:true, devel:true, maxerr:50 */ …
Run Code Online (Sandbox Code Playgroud)

javascript wordpress tinymce visual-editor tinymce-4

7
推荐指数
1
解决办法
2635
查看次数

如何在jquery中检查div是否有多个类的类

我有一个动态div,可以生成超过1000个不同的类...它是一个wordpress主题.

现在我想检查div是否有52个类之一.

.bg1,.bg2,.bg3等等......

我知道你可以使用hasClass();

但是我如何检查每一个然后获得价值.例如,这里是div

<div id="wordpresspost" class="bodyclass post-id-193 wordpresswrap bg1"></div>
Run Code Online (Sandbox Code Playgroud)

请记住,我真的不知道jquery:D

我以为它会是这样的,但逻辑上这对我来说没有意义:(

var divclass = $("#wordpresspost").hasClass('bg1, bg2, bg3, bg4, bg5, bg6');

if(divclass == true){
    var divsclass = $(this);
}
Run Code Online (Sandbox Code Playgroud)

我需要知道这个类,因为我想要改变它,例如我想.removeClass然后addClass一个新类而不改变其他类,因为它们是动态的

在此先感谢您的建议:)

javascript jquery

5
推荐指数
2
解决办法
1456
查看次数

来自脚本的格式错误的标题 错误的标头= 1:index.php

我有一个现在已有几年的网站,它基本上提供下载.

无论如何,因为移动服务器的人无法下载文件,因为它现在给出错误500错误,并且在日志文件中它带来了这个错误:

来自脚本的格式错误的标题 错误的标头= 1:index.php

我能看到的与此相关的唯一代码是:

// Echo $productOptionDetails->file;                
$file = DOWNLOAD_FOLDER. '/'. $productOptionDetailEntity->file;

    if (file_exists($file)) {

        header('Content-Description: File Transfer');
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename='.basename($file));
        header('Content-Transfer-Encoding: binary');
        header('Expires: 0');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
        header('Content-Length: ' . filesize($file) + 1);
        ob_clean();
        flush();
        readfile($file);
        exit;
    }
Run Code Online (Sandbox Code Playgroud)

现在如果我输出:

// Echo $productOptionDetails->file;                
$file = DOWNLOAD_FOLDER. '/'. $productOptionDetailEntity->file;

if (file_exists($file)) {
   readfile($file);
   exit;
}
Run Code Online (Sandbox Code Playgroud)

它会输出大量加密文本,因此它显然可以阅读.

我读过的是标题不正确但在阅读了php.net以及其他网站中的内容后,这看起来很好.

任何人都可以大声说出我为什么会收到这些错误?

谢谢

php malformed http-headers

5
推荐指数
1
解决办法
1万
查看次数

SELECT FROM Table WHERE 不部分的确切数字位于字符串 SQL 中

我有一个表,其中包含一堆用逗号分隔的数字。

我想从表中检索字符串中包含确切数字而不是部分数字的行。

例子:

CREATE TABLE IF NOT EXISTS `teams` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `uids` text NOT NULL,
  `islive` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;

INSERT INTO `teams` (`id`, `name`, `uids`, `islive`) VALUES
(1, 'Test Team', '1,2,8', 1),
(3, 'Test Team 2', '14,18,19', 1),
(4, 'Another Team', '1,8,20,23', 1);
Run Code Online (Sandbox Code Playgroud)

我想搜索 1 在字符串中的位置。

目前,如果我使用 Contains 或 LIKE,它会返回所有带有 1 的行,但 18、19 等不是 1,但其中确实有 1。

我在这里设置了一个sqlfiddle

我需要做正则表达式吗?

regex mysql sql contains sql-like

4
推荐指数
1
解决办法
1075
查看次数

致命错误:未找到类'WP_Customize_Control' - WordPress

我正在构建自己的wordperss主题,当开始使用WordPress定制器主题选项时,我遇到了一些麻烦.

基本上我试图创建一个textarea和我读过的东西我需要创建一个扩展类,然后在WordPress的add_control函数下调用它.

我已经尝试过这一切,并且在定制器模式下一切运行良好但是一旦我进入网站的任何其他部分,我就会收到此错误:

致命错误:找不到类'WP_Customize_Control'

正如我所说,它在定制器中100%工作,它是自己的,但任何其他页面,包括管理员,我收到此消息.

这是班级:

class ublxlportfolio_textarea extends WP_Customize_Control {
    public $type = 'textarea';

    public function render_content() {
        ?>
        <label>
        <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
        <textarea rows="5" style="width:100%;" <?php $this->link(); ?>><?php echo esc_textarea( $this->value() ); ?></textarea>
        </label>
        <?php
    }
}
Run Code Online (Sandbox Code Playgroud)

我需要将其包装在条件标签中吗?如果是这样那将是什么?

我做错了吗?

php wordpress wordpress-theming

3
推荐指数
3
解决办法
6050
查看次数

在php中将文件从一个文件夹移动到另一个文件夹

我有点卡在这里.

我希望能够将已经上传的文件移动到另一个文件夹.

例如:

用户上传并进入名为"upload_temp/image.jpg"的临时文件夹,现在我想将其移至"resources/user_images/profile/image.jpg"

我已经尝试了显而易见的重命名(),但由于某种原因这不起作用.

php upload

2
推荐指数
1
解决办法
8850
查看次数

检查字符串和htmlentities预先的一切

我正在尝试编写评论表单.

我正在考虑使用strstr来查找是否<pre>存在以及是否确实使用htmlentities将其中的所有内容都转换为html.

但我遇到的问题是实际上在转换前的所有内容.

我的代码变为现实,但如何替换.

我正在看preg_replace但我的正则表达式真的很差:)

例:

$string = 'This is a form with <pre>Everything in this needs to be htmlentities() </pre> and everything outside needs to be normal.';
Run Code Online (Sandbox Code Playgroud)

php regex preg-replace

2
推荐指数
1
解决办法
273
查看次数

使用 Tinymce 文本编辑器首次发送时内容文本区域为空

我以前从未遇到过这种情况,这就是为什么我来看看是否有人可以解释为什么或导致这种情况的原因。

基本上我使用以下 html javascript 在 Tinymce 编辑器中调用:

<script type="text/javascript">
    jQuery(document).ready(function() {
        tinymce.init({
            selector: "#content",
            theme: "modern",
            plugins: [
            "advlist autolink lists link image charmap print preview anchor",
            "searchreplace visualblocks code fullscreen",
            "insertdatetime media table contextmenu paste imagetools Customlayouts Customshortcodes, autoresize responsivefilemanager"
            ],
            toolbar: "Customlayouts Customshortcodes | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist | link responsivefilemanager image media | code fullscreen",
            image_advtab: true ,
            relative_urls: false,
            external_filemanager_path:"http://<?php echo $_SERVER['HTTP_HOST']; ?>/Libs/filemanager/",
            filemanager_title:"Responsive Filemanager" ,
            external_plugins: { …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery tinymce

2
推荐指数
1
解决办法
1547
查看次数