send_data函数从createNewTable函数调用(onclick)。 我不明白为什么我的函数在action_id ===" new_table_btn"(action_id it' s指示符)时进入无限循环。请帮帮我
HTML
<button type="submit" class="btn btn-default" onclick="createNewTable()">Send</button>
的JQuery / AJAX
function createNewTable()
{
_table_name = $("#table_name").val();
var data = "Indicator=new_table&table_name=" + _table_name + "&player_email=" + player_email;
send_data(data, "new_table_btn");
}
function send_data(j_data, action_id) {
var results;
//var k_data = [{aaaa:"solange"}];
$.ajax({
url: "SrvController",
dataType: 'json',
type: 'post',
//contentType: 'application/json',
data: j_data, // "Indicator=world_games&player_email=dana@mmm.com", //"aaaa=lllll&aaa=pppp",//JSON.stringify(k_data),
//processData: false,
success: function (data, textStatus, jQxhr) {
if (action_id === "join_table")
{
// turn_place =
if (data["status"] === "success")
{
player_place = data["sit"];
$("#playground").hide("slow", arguments.callee);
$("#startGame").show("slow");
if (!read_data)
{
new_round_data();
read_data = true;
}
}
else
$("#playground").append("fail");
}
if (action_id === "world_games")
{
read_activ_tables(data);
}
if (action_id === "new_round_data")
{
new_round(data);
}
if (action_id === "get_table_id")
{
_table_number = data["tableNumber"];
var data = "Indicator=join_table&table_id=" + _table_number + "&player_email=" + player_email;
send_data(data, "join_table");
}
if (action_id === "new_table_btn")
{
if (typeof data !== "undefined")
_table_number = data["tableId"];
player_place = "1";
$("#playground").hide("fast", arguments.callee);
$("#startGame").show("slow");
if (!read_data)
{
read_data = true;
new_round_data();
}
}
},
error: function (jqXhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
//results.innerHTML = "processing...";
}