Skip to content

Instantly share code, notes, and snippets.

@mlzboy
Created November 28, 2018 01:16
Show Gist options
  • Save mlzboy/76a307b8009322cd3d94fd3c0f7d5fde to your computer and use it in GitHub Desktop.
Save mlzboy/76a307b8009322cd3d94fd3c0f7d5fde to your computer and use it in GitHub Desktop.
var result = [];
function mselect(i)
{
var str_i = "";
if (i < 9)
{
str_i = "0"+ (i+1).toString();
}
else
{
str_i = (i+1).toString();
}
var question_id = "#GridView2_ctl"+str_i+"_Label15";
var question = $(question_id).text();
var course = $("#drop1 option:selected").text()
var exam = $("#drop2 option:selected").text()
var id = "#GridView2_ctl"+str_i+"_Label16";
var answer = $(id).text();
var a_id = "#GridView2_ctl"+str_i+"_Label17";
var a = $(a_id).text();
var b_id = "#GridView2_ctl"+str_i+"_Label18";
var b = $(b_id).text();
var c_id = "#GridView2_ctl"+str_i+"_Label19";
var c = $(c_id).text();
var d_id = "#GridView2_ctl"+str_i+"_Label20";
var d = $(d_id).text();
var data = {"question":question,"a":a,"b":b,"c":c,"d":d,"answer":answer,"course":course,"exam":exam,"no":i.toString()};
data["type"]="mutiple";
var e_option_id = "#GridView2_ctl" + str_i + "_Label21";
if ($(e_option_id).text().trim().length != 0)
{
var e_id = "#GridView2_ctl"+str_i+"_Label21";
data["e"] = $(e_id).text();
}
var f_option_id = "#GridView2_ctl" + str_i + "_Label22";
if ($(f_option_id).text().trim().length != 0)
{
var f_id = "#GridView2_ctl"+str_i+"_Label22";
data["f"] = $(f_id).text();
}
console.log(data);
result.push(data);
}
$.ajax({
type: "post",
url: 'http://192.168.50.116:1323/',
async: false, // 使用同步方式
// 1 需要使用JSON.stringify 否则格式为 a=2&b=3&now=14...
// 2 需要强制类型转换,否则格式为 {"a":"2","b":"3"}
data: JSON.stringify(result),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
console.log(data);
} // 注意不要在此行增加逗号
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment