有一个text
名为 fiche_tache_ref 的 HTML 元素。在javascript
页面文件夹之外的文件(.js)内,我想根据所选列表框的值设置其值:
function changerNatureRefTache(nature_tache_id) { // nature_tache_id is from a listbox
var http_ajax = $('#http_ajax').val();
var html = $.ajax({
data: "nature_tache_id="+nature_tache_id ,
type: "POST",
url: http_ajax+"referentiel/AjaxTacheChangerNatureTache.php" ,
async: false
}).responseText;
// here I want to set the value of the field
}
AjaxTacheChangerNatureTache.php 的代码是:
<?php
if (isset($_POST['nature_tache_id'])) {
define("ROOT_PATH", "../../");
require_once ROOT_PATH . 'config.inc.php';
require_once RP_MODELS . 'nature_tache.class.php';
$db = new DbConn();
$obj = new nature_tache($db->getInstance());
$ret = $obj->recupererNatureTache($_POST['nature_tache_id']);
$code = $ret['nat_code'];
echo $code;
}
?>
那么如何设置字段的值JQuery
呢?