我在开发的webapp中遇到错误,我确信这是一个非常基本的错误.
每当我在网上运行此代码时,chrome debbuger都会返回此错误:
POST http://my_ip/server_wrapper.php 500 (Internal Server Error)
Run Code Online (Sandbox Code Playgroud)
这是JQUERY,js文件片段"
this.post = function () {
$.post ("server_wrapper.php",
{
_id: this.id,
_question: this.question,
_type: "none"
},
function (data, status) {
alert ("DATA: " + data + " status: " + status);
}
);
}
Run Code Online (Sandbox Code Playgroud)
这是php文件:
<?php
if (isset($_POST["_question"]) && isset($_POST["_type"]) && isset($_POST["_id"])) {
$question = $_POST["_question"];
$type = $_POST["_type"];
$id = $_POST["_id"];
$con = mysqli_connect ("localhost", "user", "pass", "database");
if (mysqli_connect_errno($con)) {
echo "Failed to connecto to …Run Code Online (Sandbox Code Playgroud) 我正在尝试将数组中的图像放入div中.
arralegro =[ "01.png", "02.png", "03.png", "04.png"];
n=2;
var goImg = 'alegro/' + arralegro[n];
alert (goImg); //correct - `alegro/02.png`
$('#divR').empty();
$("#divR").prepend('<img id="slide" src=' + goImg + '/>'); // here is something wrong
Run Code Online (Sandbox Code Playgroud)
萤火虫说 - 404 Not Found.但是图像在那里.
$("#divR").prepend('<img id="slide" src="alegro/02.png"/>'); // works this way
Run Code Online (Sandbox Code Playgroud) 寻求有关通过functions.php或Wordpress中的任何其他位置插入此代码的帮助.我试过这个似乎不起作用......我在源代码中看不到它
<?php
function add_this_script_footer(){ ?>
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://stats.domain.com/statsapp/";
_paq.push(["setTrackerUrl", u+"piwik.php"]);
_paq.push(["setSiteId", "445"]);
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
})();
</script> <?php }
add_action('wp_footer', 'add_this_script_footer'); ?>
Run Code Online (Sandbox Code Playgroud)
谢谢您的帮助.
`
我有一个包含纯文本文件的模型文件.例如,Github Gists有这个url结构:https://gist.githubusercontent.com/140bytes/962807/raw/dfb480a5038214d152544bddb412dfe2e8656413/LICENSE.txt .
要做到这一点,我应该覆盖fetch/save/etc,还是应该覆盖模型的同步?
var File = Backbone.Model.extend({
path: '',
contents: '',
initialize: function(options) {
this.path = options.path || '';
},
fetch: function() {
// Do I override fetch/save/etc?
$.get(this.path).done(function(contents) {this.contents = contents});
},
sync: function (method, model, options, error) {
// Or do I override sync?
}
});
Run Code Online (Sandbox Code Playgroud)
我试图根据字母值对哈希图进行排序,该值本身存储在另一个Map中.
结构如下:
Map<String, HashMap<String, String>>
我想根据HashMap里面的值对这个Map进行排序,这样就可以根据HashMap的值对所有完整的地图进行排序,以便作为HashMap进行排序.
- 更新:
例如,如果我有类似的东西:
Map: abc Value: HashMap[EN, a]
Map: xyz Value: HashMap[DE, c]
Map: pqr Value: HashMap[PL, b]
Run Code Online (Sandbox Code Playgroud)
排序后应该是这样的:
Map: abc Value: HashMap[EN, a]
Map: pqr Value: HashMap[PL, b]
Map: xyz Value: HashMap[DE, c]
Run Code Online (Sandbox Code Playgroud)
如何进行?
我正在构建我的第一个rails应用程序,并希望实现类似帖子的类似按钮.我可以找到的关于如何执行此操作的大多数资源都涉及使用AJAX.我想知道是否有办法在不使用AJAX的情况下实现类似的按钮?
我有一个字符串$text_arr="101104105106109111112113114116117120122123124"
相当大的字符串
如果我想从他们中拆分三个数字101,104,105并存储它们.$array我该怎么办?
我试过这样做:
preg_match_all('/[0-9]{3}$/',"$text_arr",$array);
Run Code Online (Sandbox Code Playgroud) 例如,我有这种内容
<div id="t1" class="tt" tag='t2"><div class="t3">tee</div><a href='#'>test</a><span>test</span><div>asdf</div></div>
<div id="t1" class="tt" tag='t2"><div class="t3">tee</div><a href='#'>test</a><span>test</span><div>asdf</div></div>
Run Code Online (Sandbox Code Playgroud)
我试图使用preg_match来获取父div之间的内容,所以这里父div意味着<div id="t1".我使用preg_match还是有其他方法来获取这些div之间的数据?
我一直试图让这个代码工作(http://jsfiddle.net/2DY8M/9/),该文件是在我的桌面上的文件夹在一个单一的HTML文档.我尝试将脚本放在关闭头标记的上方和下方,并尝试链接到同一文件夹中的本地jquery文件,但我得到了相同的结果.
在浏览器中,单击链接时目标框中没有任何内容.
这是代码
<DOCTYPE html>
<html>
<head>
<style media="screen" type="text/css">
.contentleft{
border:1px solid green;
width:30%;
float:left;
}
.contentright{
border:1px solid red;
width:64%;
float:right;
height:400px;
}
.selectboxcontent{
width:100%;
height:100px;
background:#ccc;
display:none;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
$('.selectBox').click(function() {
$('selectBoxContent').toggle("slide");
return false;
});
});
</script>
</head>
<body>
<div class="contentleft">
<ul>
<li><a class="selectBox" href="">sample</a></li>
<li><a class="selectBox" href="">sample1</a></li>
<li><a class="selectBox" href="">sample2</a></li>
</ul>
</div>
<div class="contentright">
<div class="selectBoxContent">its</div>
<div class="selectBoxContent">my</div>
<div class="selectBoxContent">way</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud) 这是我所拥有的网站表单的底部.在添加TOS协议复选框之前,一切正常.现在,无论是否选中该框,它都会提醒用户必须选中该框.任何帮助将不胜感激.
<input type='checkbox' value='yes' name='tosagree' id='tosagree'> <p>I have read and agree to the privacy policy and terms of use found on this site.</p>
<input type='submit' id='submit' name='submit' value='submit'><br /><br />
</form>
</div>
<script type='text/javascript'>
function validateForm()
{
var asking=document.forms["form"]["asaskingprice"].value,
reasons=document.forms["form"]["asreasons"].value,
timelines=document.forms["form"]["astimelines"].value,
sources=document.forms["form"]["assources"].value,
tos=document.forms["form"]["tosagree"].value;
if (asking==null || asking=="")
{
alert("Asking price must be filled out");
return false;
}
if (reasons==null || reasons=="")
{
alert("reasons must be filled out");
return false;
}
if (timelines==null || timelines=="")
{
alert("timelines must be filled out"); …Run Code Online (Sandbox Code Playgroud) 有没有办法使用以下代码:
$(document).ready(function () {
$('sd').hover(function() {
$(this).addClass('a');
}, function() {
$(this).removeClass('a');
});
});
Run Code Online (Sandbox Code Playgroud)
不在我的代码中包含jquery文件?例如,有没有办法用纯JavaScript做同样的事情?
如果我有一个包含以下内容的字符串,是否可以添加所有数字并删除逗号?
$string = "1,2,3,4,5,6,";
Run Code Online (Sandbox Code Playgroud)
我尝试了一些选项,但无法弄清楚如何.
谢谢
我需要使用功能cartesian从List::Gen.这个函数需要LIST作为第二个参数,但我有一个数组,比如
$VAR1 = [
[
1,
2,
3
],
[
'a',
'b',
'c'
],
[
'x'
]
];
Run Code Online (Sandbox Code Playgroud)
如何将这样的数组"转换"成列表,这样cartesian可以使用?在这种情况下,将数组放入列表上下文似乎不起作用.