我尝试使用AJAX调用一个python文件,该文件将基本的“hello”返回到HTML文件。你知道吗
我面临的问题是,AJAX的“错误”部分即使在成功执行之后也会被调用
AJAX请求
$.ajax({
'url': 'http://localhost/keywordSearch.py',
'success': function(response){
alert(response.responseText);
},
'error': function(error){
$('.table-responsive').html('');
$().toastmessage('showToast', {
text : 'Unable to get data now. Please try after sometime.',
sticky : false,
stayTime : 2000,
position : 'middle-center',
type : 'warning'
});
console.log(error.responseText);
}
});
Python文件:sample.py你知道吗
#!/Python27/python
print "Content-type: text/html;charset:utf-8"
print
print "hello"
我们在html控制台中得到的输出是“hello”,表示它来自“error”,如果它来自alert,则表示“success”。你知道吗
我不明白为什么像这样的基本程序也会执行错误, 谢谢你的帮助
目前没有回答
相关问题 更多 >
编程相关推荐