我会通过使用jQuery $.ajax
函数解决这个问题,但在这种情况下jQuery不是选项.相反,我将使用CORS请求.我觉得响应请求的网络服务器出了问题,我很难搞清楚问题所在.
这是我创建CORS请求的代码
var httpRequest = new XMLHttpRequest();
httpRequest.open('POST', url, true);
httpRequest.setRequestHeader( 'Access-Control-Allow-Origin', '*');
httpRequest.setRequestHeader( 'Content-Type', 'application/json' );
httpRequest.onerror = function(XMLHttpRequest, textStatus, errorThrown) {
console.log( 'The data failed to load :(' );
console.log(JSON.stringify(XMLHttpRequest));
};
httpRequest.onload = function() {
console.log('SUCCESS!');
}
Run Code Online (Sandbox Code Playgroud)
这是console.log错误:
XMLHttpRequest无法加载 http://test.testhost.com/testpage.请求标头字段Access-Control-Allow-Origin不允许使用Access-Control-Allow-Origin.
以下是标题信息:
> Remote Address:**.**.***.**:80 Request
> URL:http://test.testdomain.com/testpage Request
> Request Method:OPTIONS
> Status Code:200 OK
Run Code Online (Sandbox Code Playgroud)
请求标题:
OPTIONS /content-network HTTP/1.1
Host: test.testhost.com
Connection: keep-alive
Cache-Control: no-cache
Pragma: no-cache
Access-Control-Request-Method: POST
Origin: http://test.testdomain.com
User-Agent: Mozilla/5.0 (Macintosh; Intel …
Run Code Online (Sandbox Code Playgroud) 我有一个JSON对象,没有给出三个值的键(每个都是一个数组),我想解析它们.我怎么能在JQuery中这样做?
[
{
"cid": "3",
"pid": "0",
"nid": "12",
"uid": "4",
"subject": "test2",
"hostname": "127.0.0.1",
"created": "1374084646",
"changed": "1374084645",
"status": "1",
"thread": "02/",
"name": "chrisr",
"mail": "",
"homepage": "",
"language": "en",
"uuid": "e4729a69-7f6f-4091-98a0-0a040fe683f1",
},
{
"cid": "2",
"pid": "0",
"nid": "13",
"uid": "4",
"subject": "TEST comment 2",
"hostname": "127.0.0.1",
"created": "1374072245",
"changed": "1374072244",
"status": "1",
"thread": "01/",
"name": "chrisr",
"mail": "",
"homepage": "",
"language": "en",
"uuid": "b4d5a084-8aa3-4828-b6e4-17396cbaf2f6",
},
{
"cid": "1",
"pid": "0",
"nid": "12",
"uid": "4",
"subject": "test comment", …
Run Code Online (Sandbox Code Playgroud) 我有一个 CSV 文件,在这种情况下,第一个“单元格”只是一个整数 9。下一行是第一个“单元格”的 10,依此类推。当我做$array = fgetcsv($file);
第一行的第一个单元格时,值前面有这些奇怪的字符:??
它搞乱了我的数据库导入,因为这个单元格应该只包含一个整数。它只发生在第一行的第一个单元格上。
关于为什么会发生这种情况以及我可以做些什么来避免这种情况的任何想法?
我的 bash 脚本中有两个软件版本检查没有按我预期的那样工作。
DRUSH_VERSION="$(drush --version)"
echo ${DRUSH_VERSION}
if [[ "$DRUSH_VERSION" == "Drush Version"* ]]; then
echo "Drush is installed"
else
echo "Drush is NOT installed"
fi
GIT_VERSION="$(git --version)"
echo ${GIT_VERSION}
if [[ "GIT_VERSION" == "git version"* ]]; then
echo "Git is installed"
else
echo "Git is NOT installed"
fi
Run Code Online (Sandbox Code Playgroud)
回复:
Drush Version : 6.3.0
Drush is NOT installed
git version 1.8.5.2 (Apple Git-48)
Git is NOT installed
Run Code Online (Sandbox Code Playgroud)
同时,如果我改变
DRUSH_VERSION="${drush --version)"
到
DRUSH_VERSION="Drush 版本:6.3.0"
它回应
Drush 已安装
现在我将使用
如果输入 -p drush; …
我正在尝试在Dockerfile中安装nvm。似乎安装成功,但是nvm
命令不起作用。
Dockerfile:
# Install nvm
RUN git clone http://github.com/creationix/nvm.git /root/.nvm;
RUN chmod -R 777 /root/.nvm/;
RUN sh /root/.nvm/install.sh;
RUN export NVM_DIR="$HOME/.nvm";
RUN echo "[[ -s $HOME/.nvm/nvm.sh ]] && . $HOME/.nvm/nvm.sh" >> $HOME/.bashrc;
RUN nvm ls-remote;
Run Code Online (Sandbox Code Playgroud)
构建输出:
Step 23/39 : RUN git clone http://github.com/creationix/nvm.git /root/.nvm;
---> Running in ca485a68b9aa
Cloning into '/root/.nvm'...
---> a6f61d486443
Removing intermediate container ca485a68b9aa
Step 24/39 : RUN chmod -R 777 /root/.nvm/
---> Running in 6d4432926745
---> 30e7efc5bd41
Removing intermediate container 6d4432926745
Step 25/39 : …
Run Code Online (Sandbox Code Playgroud) 我scrollTop
在每个字母的单击函数的联系人号码列表中使用了JQuery函数.它滚动到它应该的位置,但然后立即滚动回到顶部.
以下是代码中函数的示例:
$('.a').click(function(){
$('html, body').animate({scrollTop:$('#A').position().top}, 'slow');
});
Run Code Online (Sandbox Code Playgroud)
这是我为它制作的JSFiddle:http: //jsfiddle.net/CR47/MdtSE/
<form name="makeup" action="index.php" method="post">
<select id="skin_shade">
<option value="skin_shade_1">Dark</option>
<option value="skin_shade_2">Light</option>
</select></br>
Acne:<input type="checkbox" value="acne"/></br>
Oil:<input type="checkbox" value="oily"/></br>
Straight Hair:<input type="checkbox" value="straight"/></br>
<input type="submit" value="Submit"/>
</form>
<?php
echo $_POST['skin_shade']?>;
Run Code Online (Sandbox Code Playgroud)
我点击提交后没有输出,除了表单重置.
这是我的数组:
$person = array(
"fullname" => $fn,
"skin_shade" => $_POST['skin_shade'],
"acne" => $_POST['acne'],
"dry_skin" => $_POST['dry_skin'],
"oily_skin" => $_POST['oily_skin'],
"wrinkles_aging" => $_POST['wrinkles_aging'],
"sensative_skin" => $_POST['sensative_skin'],
"darkspots" => $_POST['darkspots'],
"hair_type" => $_POST['hair_type'],
"parabens" => $_POST['parabens'],
"sulfates" => $_POST['sulfates'],
"mineral_oil" => $_POST['mineral_oil'],
"silicones" => $_POST['silicones'],
"relaxed" => $_POST['relaxed'],
"colortreated" => $_POST['colortreated'],
"thinning" => $_POST['thinning'],
"growth" => $_POST['growth'],
"braidout" => $_POST['braidout'],
"roller" => $_POST['roller'],
"wng" => $_POST['wng'],
"heat" => $_POST['heat'],
"wig" => $_POST['wig'],
"braid" => $_POST['braid'],
"dreadlocks" => $_POST['dreadlocks'],
"henna" => $_POST['henna'],
"hair_color" …
Run Code Online (Sandbox Code Playgroud) 就像标题所说,我有一个表单的提交按钮,我想要禁用,除非文本框中有文本.该字段已正确禁用,但输入文本后,提交仍保持禁用状态.
这是HTML:
<form method="get" action="#">
<input type="text" id="edit-combine" name="combined"/>
<input type="submit" id="edit-submit-clone-of-combined-search" value="search"/>
</form>
Run Code Online (Sandbox Code Playgroud)
这是jquery:
if($('#edit-combine').val().length == 0){
$('#edit-submit-clone-of-combined-search').prop("disabled", true);
}else{
$('#edit-submit-clone-of-combined-search').prop("disabled", false);
}
Run Code Online (Sandbox Code Playgroud)
我为此做了一个JSFiddle:http://jsfiddle.net/CR47/ZUmCp/