我在下面有这个 js 和 qunit 测试。为什么浏览器给我的 listClasses 没有定义?如何解决它。我看到的大多是
function ajax() {
$.ajax({
});}
但如果我喜欢下面如何进行测试?
$('#MregisteredClasses').on('pageinit', function listClasses(){
var rowInput = "1";
var pageInput = "1";
$.ajax({
url: 'http://137.57.102.146:8080/Training/getRegisteredClassesData.html',
data: ( {rows : rowInput , page : pageInput}),
type: 'POST',
success: function(json_results){
$('#list').append('<ul data-role="listview" data-inset="true"</ul>');
listItems = $('#list').find('ul');
$.each(json_results.rows, function(key) {
html = "<li data-mini='true' id='icon'><a href='http://137.57.102.146:8080/Training/MRegisteredClassesDetail.phone?courseId="
+ [json_results.rows[key].courseId] + "®No=" + [json_results.rows[key].regNo] +
"' rel='external'>" + json_results.rows[key].courseName+ "</a>"
+ "<a href='http://137.57.102.146:8080/Training/MRateCourse.phone?courseId="
+ [json_results.rows[key].courseId] + "®No=" + [json_results.rows[key].regNo] +
"' rel='external'>RATE THIS COURSE</a></li>" ;
listItems.append(html);
});
$('#list ul').listview();
},
});
});
这是 qunit 测试
test('asynchronous test', function() {
// Pause the test, and fail it if start() isn't called after one second
stop();
listClasses(function() {
// ...asynchronous assertions
ok(true, "Success");
});
setTimeout(function() {
start();
}, 2000);
});