jquery.get从php到另一个输入的结果
我正在使用以下代码:jquery.get从php到另一个输入的结果,php,jquery,ajax,get,slug,Php,Jquery,Ajax,Get,Slug,我正在使用以下代码: $('#inputname').change(function(){ //on change event var parentVal = $('#inputname').val(); $.ajax({ url : 'file.php', type : 'GET', //type of request, GET or POST
$('#inputname').change(function(){ //on change event
var parentVal = $('#inputname').val();
$.ajax({
url : 'file.php',
type : 'GET', //type of request, GET or POST
data: ({ svalue: parentVal }),
success : function(data){ $('#slug').html(data); }
});
});
我想在php中处理后,将在一个文本字段中键入的内容显示到另一个文本字段中。在php文件中,我只有一个用于测试的echo$\u GET['svalue']
有什么想法吗?谢谢大家! 如果是文本字段,请使用
.val
而不是.html
$('#slug').val(data);
我有一些东西要分享,可能对你有帮助。 在何处使用:
use .html() to operate on containers having html elements.
use .text() to modify text of elements usually having separate open and closing
tags
不使用的地方:
.text() method cannot be used on form inputs or scripts.
.val() for input or textarea elements.
.html() for value of a script element.
Picking up html content from .text() will convert the html tags into html
entities.
区别:
.text() can be used in both XML and HTML documents.
.html() is only for html documents.
你能把问题说清楚吗。。??