[英]Jquery: html, text and append functions are not working
I have a simple code to make requisition by ajax. 我有一个简单的代码可以通过ajax进行申请。
<script type="text/javascript" src="{{ url_for('static', filename='jquery-2.2.4.min.js') }}"></script>
<script type="text/javascript">
$(document).ready(function() {
$('form').submit(function (e) {
var url = "{{ url_for('ajaxPage') }}";
$.ajax({
type: "POST",
url: url,
data: $('form').serialize(),
dataType:'json',
success: function (data) {
var text= "Anything here!";
$('div.panel-body').html(text); //Not Working
$('div.panel-body').text(text); //Not Working
$('div.panel-body').append(text); //Not Working
alert(text); //Working
console.log(text); //Working
}
});
e.preventDefault();
});
});
</script>
Here body layout: 这里的车身布局:
<body>
<div class="panel-body"> // Waiting content </div>
</body>
Ajax is working perfectly, I can view my array using console.log, alert, but I can not use HTML(), TEXT() and APPEND() . Ajax运行正常,我可以使用console.log查看所有数组,但不能使用HTML(),TEXT()和APPEND() 。 Where is my mistake? 我的错误在哪里? I already change JS file and I have other page with the same code and it works fine! 我已经更改了JS文件,并且使用相同的代码创建了其他页面,并且效果很好!
My Network page 我的网络页面
Updating body page 更新正文页
<div class="input-group">
<form method="POST" name='form'>
<input type="text" name="inputxt" class="form-control" size="20">
<button type="submit">Search</button>
</form>
</div>
<div class="panel-body">
</div>
我重新创建了此页面,问题出在DIV中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.