Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery.get从php到另一个输入的结果_Php_Jquery_Ajax_Get_Slug - Fatal编程技术网

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.

你能把问题说清楚吗。。??