[英]jQuery Ajax not updating textarea
SO this is suposed to detect when my slect drop-down menu in the form changes, make an ajax call and change the contents of a textarea to the returned data from the AJAX call. 这样就可以检测出表单中的我的slect下拉菜单何时发生变化,进行ajax调用,并将textarea的内容更改为从AJAX调用返回的数据。 After tests it all works except it seems to refuse to return the contents of the ajax call. 经过测试后,除了似乎拒绝返回ajax调用的内容之外,所有其他方法均有效。
Heres the jQuery: 继承人的jQuery:
$("select#vars").change(function(){
var name = $("select#vars").val();
$.ajax({
url:"sys/get_var.php?name=" + encodeURIComponent(name),
success:function(datas) {
$("textarea#var_value").val(datas);
}
});
});
Any ideas? 有任何想法吗?
If you want the data to be returned then use the dataType: 'json'. 如果要返回数据,请使用dataType:'json'。
Check out the following piece of code does this :- 看看下面的代码可以做到这一点:
$.ajax({
url : 'your_url_path',
type : 'GET',
dataType: 'json',
data : {name1:name},//left side 'name1' is used to access the value like $_GET['name1']
success : function(retuObj){
//on success your code
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.