使用BackBone我发送变量和数组以发送调用以发送到数据库。我能够获得变量。但是当我尝试访问数组时,它会转到ERROR并且无法访问该数组。这是发送方式是否正确?
addQuestion: function (event) {
var question = $('#txtQuestion').val();
var correctAns = $('#txtCorrectAns').val();
var options = ["Saab", "Volvo", "BMW"];
var data = {question: question, catID: catID, correctAns: correctAns, options: options};
Backbone.ajax({
type: 'POST',
ansyc: false,
url: "http://localhost/TEST/index.php/Rest_API/RestAPI/question",
data: data,
dataType: 'json',
success: function (val) {
alert("Success");
},
error: function (erorr) {
alert("Failed");
}
});
}
function question_post() {
$question = $this->post('question');
$catID = $this->post('catID');
$correctAns = $this->post('correctAns');
$options = $this->post('options');
$this->load->model('QuestionModel');
$response = $this->QuestionModel->addQuestion($question,$catID,$correctAns);
$this->response($response);
}