小编Vai*_*pta的帖子

jquery .text()或.html()不起作用

我正在动态生成div并希望通过html()/ text()更改其内容,但它不起作用.

这是代码:

var div = '<div class="ps_album"><img alt="" src="images/1px.gif" class="thmb"><div class="ps_desc"><h2>title</h2></div></div>';

$(div).find('.ps_desc').html('<h1>Hello</h1>');
$(div).appendTo('body');
Run Code Online (Sandbox Code Playgroud)

在上面的代码中,第3行即

$(div).find('.ps_desc').html('<h1>Hello</h1>');
Run Code Online (Sandbox Code Playgroud)

不工作..为什么?

jquery

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

html在wamp中不解析为php

我在我的.htaccess文件中使用此片段将html解析为php:

<FilesMatch "\.(html|htm|txt)$">
 SetHandler application/x-httpd-php5
</FilesMatch>
Run Code Online (Sandbox Code Playgroud)

这在我的网站(在线)工作正常,但不在我的localhost(使用WAMP最新版本)..但如果我将上述代码更改为:

<FilesMatch "\.(html|htm|txt)$">
 SetHandler application/x-httpd-php
</FilesMatch>
Run Code Online (Sandbox Code Playgroud)

然后,这在我的localhost中工作正常但不在我的网站中..我必须添加/删除5in SetHandler application/x-httpd-php以在任何一方工作.

请帮我..

html php apache .htaccess wamp

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

使用curl在谷歌翻译免费API中出现400错误请求

我正在尝试使用免费的 Google Translate API,它是从 Firefox 的 S3 Google Translator 插件中提取的,即。

\n\n
https://translate.google.com/translate_a/single?client=t&sl=auto&\ntl=en&hl=en&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t\n&dt=at&ie=UTF-8&oe=UTF-8&otf=2&srcrom=1&ssel=0&tsel=0&q=Hello\n
Run Code Online (Sandbox Code Playgroud)\n\n

在 PHP cURL 中,即。

\n\n
$isPOST=isset($_POST) && !empty($_POST);\n$q=$isPOST ? $_POST['q'] : $_GET['q'];\n\n$url='https://translate.google.com/translate_a/single';\n$data='client=t&sl=auto&tl=en&hl=en&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&otf=2&srcrom=1&ssel=0&tsel=0&q='.$q;\n$ch=curl_init();\ncurl_setopt($ch, CURLOPT_HEADER, 0);\ncurl_setopt($ch, CURLOPT_NOBODY, 0);\ncurl_setopt($ch, CURLOPT_URL, !$isPOST ? $url.'?'.$data : $url);\ncurl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);\ncurl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7');\ncurl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);\ncurl_setopt($ch, CURLOPT_REFERER, $url);\ncurl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);\ncurl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);\nif($isPOST){\n    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');\n    curl_setopt($ch, CURLOPT_POST, 1);\n    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);\n}\n$return=curl_exec($ch);\ncurl_close($ch);\n
Run Code Online (Sandbox Code Playgroud)\n\n

我正在使用ajax调用此页面..

\n\n
$.ajax({\n    type: text.length>750 ? 'post' : 'get',\n    url: 'translate.php',\n    data: 'q='+text,\n    success: …
Run Code Online (Sandbox Code Playgroud)

javascript php ajax curl http-status-code-400

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

form.submit()不包括发送提交按钮

我有一个jQuery中的代码,首先使用ajax验证表单,然后重新提交相同的表单到另一个位置,但重新提交提交按钮值不发送..问题是什么?

这是js代码:

$.ajax({
    'type': 'post',
    'url': '/inc/do.php',
    'data': $form.serialize(),
    beforeSend: function(){
        $form.find(':input').attr('disabled', true);
        $form.find('.btn').addClass('bdsbld');
        $form.find('.blkr').css('display', 'block');
    },
    error: function(){
        Recaptcha.reload();
        $form.find(':input').attr('disabled', false);
        $form.find('.btn').removeClass('bdsbld');
        $form.find('.blkr').css('display', 'none');
    },
    success: function(d){
        $form.find(':input').removeAttr('disabled');
        if(res=isJSON(d)){
            if(!res.err && res.msg.toLowerCase()==='ok'){
                if(($PRI_KEY=$form.find('input#PRIVATE_KEY')).length) $PRI_KEY.val(res.PRIVATE_KEY);
                $form.append('<input type="hidden" id="PRIVATE_KEY" name="PRIVATE_KEY" value="'+res.PRIVATE_KEY+'" />');
                $form.find('input#do').val('BOOK_AD');
                $form.find('#reCaptchaO').remove();
                form.submit();
            }
            else{
                alert(res.msg);
                Recaptcha.reload();
                $form.find('.btn').removeClass('bdsbld');
                $('#'+res.fld).delay(250).focus();
            }
        }
        else
        if(d!==''){
            alert(d);
            Recaptcha.reload();
            $form.find('.btn').addClass('bdsbld');
        }
        $form.find('.blkr').css('display', 'none');
    }
});
Run Code Online (Sandbox Code Playgroud)

在这段代码中,行即ie

form.submit();
Run Code Online (Sandbox Code Playgroud)

是重新提交表单,但它不包括提交按钮及其值,但提交按钮包含在ajax请求中......为什么?

javascript ajax jquery

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

jquery自定义键码触发器无法正常工作

我想在所选元素上发送按键,如下所示:

$(":input").click(function(){
    $(this).trigger("keydown", [{
        preventDefault:function(){},
        keyCode:9,
        shiftKey: true
    }]);
});

//wants to send Shift+Tab keystroke on input click
Run Code Online (Sandbox Code Playgroud)

演示:http://jsfiddle.net/NYwCT/.

javascript jquery triggers keystroke keypress

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

帮助优化PHP中的功能

我在php中创建了一个函数来转换字符串,如:

[20110911, 20110913, [20110915, 20110918], 20110920, 20110922, 20110924, [20110926, 20110927], 20110929]
Run Code Online (Sandbox Code Playgroud)

到php数组像:

Array
(
    [0] => 20110911
    [1] => 20110913
    [2] => Array
        (
            [0] => 20110915
            [1] => 20110918
        )

    [3] => 20110920
    [4] => 20110922
    [5] => 20110924
    [6] => Array
        (
            [0] => 20110926
            [1] => 20110927
        )

    [7] => 20110929
    [8] => Array
        (
            [0] => 20111001
            [1] => 20111002
        )

    [9] => 20111004
    [10] => Array
        (
            [0] => 20111006
            [1] => 20111007
        )

) …
Run Code Online (Sandbox Code Playgroud)

php multidimensional-array

0
推荐指数
1
解决办法
116
查看次数