小编ʇol*_*qoq的帖子

如何在迭代时从"ArrayList"中删除元素时避免"ConcurrentModificationException"?

我试图删除一些元素ArrayList迭代它像这样:

for (String str : myArrayList) {
    if (someCondition) {
        myArrayList.remove(str);
    }
}
Run Code Online (Sandbox Code Playgroud)

当然,我ConcurrentModificationException试图在迭代时同时从列表中删除项目时得到一个myArrayList.有没有一些简单的解决方案来解决这个问题?

java iterator list arraylist

333
推荐指数
9
解决办法
38万
查看次数

使用Jquery AJAX提交HTML表单

我试图使用这个例子使用AJAX提交HTML表单.

我的HTML代码:

<form id="formoid" action="studentFormInsert.php" title="" method="post">
    <div>
        <label class="title">First Name</label>
        <input type="text" id="name" name="name" >
    </div>
    <div>
        <label class="title">Name</label>
        <input type="text" id="name2" name="name2" >
    </div>
    <div>
        <input type="submit" id="submitButton"  name="submitButton" value="Submit">
    </div>
</form>
Run Code Online (Sandbox Code Playgroud)

我的剧本:

<script type="text/javascript">
    $(document).ready(function() { 
        $('#formoid').ajaxForm(function() { 
            alert("Thank you for your comment!"); 
        }); 
    });
</script>
Run Code Online (Sandbox Code Playgroud)

这不起作用,我甚至没有收到警报消息,当我提交时我不想重定向到另一个页面,我只想显示警报消息.

有一个简单的方法吗?

PS:我有几个领域,我刚刚把两个作为一个例子.

ajax jquery form-submit

100
推荐指数
2
解决办法
41万
查看次数

JQuery Ajax Post导致500内部服务器错误

我正在尝试执行此AJAX帖子但由于某种原因我收到服务器500错误.我可以看到它在控制器中达到了断点.所以问题似乎在于回调.任何人?

$.ajax({
    type: "POST",
    url: "InlineNotes/Note.ashx?id=" + noteid,
    data: "{}",
    dataType: "json",

    success: function(data) {
        alert(data[1]);
    },
    error: function(data){
        alert("fail");
    }
});
Run Code Online (Sandbox Code Playgroud)

这是应该返回的字符串:

{status:'200', text: 'Something'}
Run Code Online (Sandbox Code Playgroud)

javascript ajax jquery

75
推荐指数
10
解决办法
51万
查看次数

点击按钮点击链接 - jquery

我有一个脚本如下

$('.button1').click(function() {
    document.location.href=$(this).attr('id');
});
Run Code Online (Sandbox Code Playgroud)

button1具有可变唯一ID.单击时,页面必须重定向到URL" www.example.com/index.php?id=buttonid",但现在页面仅重定向到" button id".

我想www.example.com/index.php?id=在当前网址之前添加字符串" ".我怎样才能做到这一点?

jquery response.redirect dynamic-data

27
推荐指数
3
解决办法
10万
查看次数

在C#中舍入到小数点后1位

我想将我的答案舍入小数点后1位.例如:6.7,7.3等.但是当我使用Math.round时,答案总是没有小数位.例如:6,7

这是我使用的代码:

int [] nbOfNumber = new int[ratingListBox.Items.Count];
int sumInt = 0;
double averagesDoubles;

for (int g = 0; g < nbOfNumber.Length; g++)
{
    nbOfNumber[g] = int.Parse(ratingListBox.Items[g].Text);
}

for (int h = 0; h < nbOfNumber.Length; h++)
{
    sumInt += nbOfNumber[h];
}

averagesDoubles = (sumInt / ratingListBox.Items.Count);
averagesDoubles = Math.Round(averagesDoubles, 2);
averageRatingTextBox.Text = averagesDoubles.ToString();
Run Code Online (Sandbox Code Playgroud)

c# rounding

19
推荐指数
2
解决办法
6万
查看次数

如何检查数组中是否存在给定的int?

例如,我有这个数组:

int myArray[] = { 3, 6, 8, 33 };
Run Code Online (Sandbox Code Playgroud)

如何检查给定变量x是否在其中?

我是否必须编写自己的函数并循环数组,还是在现代c ++中与in_arrayPHP 相当?

c++ arrays

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

在不使用header方法的情况下在PHP中重定向

这个contact.php表单正在处理提交,然后重定向到新页面,然后突然停止工作.我已经尝试添加错误处理,并将标题移动到所有其他前面的顶部,但都不起作用.表单仍然按预期提交数据,只是重定向不起作用.任何想法,将不胜感激.

<?php 
include 'config.php';
$post = (!empty($_POST)) ? true : false;
if($post)
{
    $email = trim($_POST['email']);
    $subject = "Downloaded Course Units";
    $error = '';
    if(!$error)
    {
        $mail = mail(WEBMASTER_EMAIL, $subject, $message, 
        "From: ".$email."\r\n"
        ."Reply-To: ".$email."\r\n"
        ."X-Mailer: PHP/" . phpversion());
        if($mail)
        {
            echo 'OK';
            header('location: http://www.google.com.au/');
            exit();
        }
    }
}
?>
Run Code Online (Sandbox Code Playgroud)

php location header

15
推荐指数
3
解决办法
6万
查看次数

Ajax将数据传递给php脚本

我正在尝试将数据发送到我的PHP脚本来处理一些东西并生成一些项目.

$.ajax({  
    type: "POST",  
    url: "test.php", 
    data: "album="+ this.title,
    success: function(response) {
        content.html(response);
    }
});
Run Code Online (Sandbox Code Playgroud)

在我的PHP文件中,我尝试检索专辑名称.虽然当我验证它时,我创建了一个警报,以显示albumname我什么都没得到,我试图获取专辑名称$albumname = $_GET['album'];

虽然它会说未定义:/

php ajax jquery

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

通过C#.Net创建/连接VPN连接

我有一个URL,一个用户名和一个密码.我想在C#.Net WinForms中建立VPN连接.

你能告诉我从哪里开始吗?任何第三方API?

代码示例将受到高度赞赏......

.net c# vpn client winforms

10
推荐指数
2
解决办法
4万
查看次数

对WinMain @ 16(codeblocks)的未定义引用

当我编译我的secrypt.cpp程序时,我的编译器显示错误" undefined reference to WinMain@16".我的代码如下

secrypt.h:

#ifndef SECRYPT_H
#define SECRYPT_H

void jRegister();

#endif
Run Code Online (Sandbox Code Playgroud)

secrypt.cpp:

#include<iostream>
#include<string>
#include<fstream>
#include<cstdlib>
#include "secrypt.h"

using namespace std;

void jRegister()
{
    ofstream outRegister( "useraccount.dat", ios::out );
    if ( !outRegister    ) {
    cerr << "File could not be opened" << endl;
    exit( 1 );}
    string a,b,c,d;
    cout<<"enter your username :";
    cin>>a;
    cout<<"enter your password :";
    cin>>b;
    outRegister<<a<<' '<<b<<endl;
    cout<<"your account has been created";

}
Run Code Online (Sandbox Code Playgroud)

trial.cpp

#include<iostream>
#include "secrypt.h"

using namespace std;

int main()
{
    void …
Run Code Online (Sandbox Code Playgroud)

c++ windows codeblocks

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