javascript - 输入字段的 PHP 计数器

标签 javascript php jquery html ajax

您好,我使用这个 PHP 脚本 http://www.stevedawson.com/scripts/text-counter.php

为了让它出现在我的 html 页面上,我使用了这个 ajax 脚本。

<script>

$.ajax({
    type:'GET',
    url:'http://www.solariserat.se/count.php',
    data:'',
    success: function(data){
            $('#container').html(data);
    }
});

</script>

加上这段html代码

<div id="container">    
<?php include "count.php"; ?>
</div>

它工作得很好,它在 div 中显示计数的数字。

但我希望它显示为输入标签内的值 这可能吗?我该怎么做?

我知道这是错误的,但你明白我的意思 =)

<input value="count.php">

最佳答案

这应该有效:

<input value="<?php include "count.php"; ?>">

然而,更简洁的方法是在呈现 <input> 的 PHP 页面中包含计数值。所以你可以这样做:

<input value="<?= count ?>">

关于javascript - 输入字段的 PHP 计数器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27532017/

相关文章:

javascript - 从类名访问 FontAwesome unicode

javascript - 如何在 Angular2 中对成功的 HTTP 请求使用回调函数?

javascript - 根据您选择的按钮创建一个元素

php - 不允许我使用 where 子句插入值

php - PHP中的mysql_fetch_array()错误

php - 从 php 使用 Selenium2 运行 Mink

javascript - 使用 JQuery 从表单获取 javascript 多维数组

javascript - 如何将一个div的文本动画化?

javascript - 使用 jquery 更新特定类 div 中的文本

javascript随机数寻找不存在的hasClass