There is a HTML element of type text
whose name is fiche_tache_ref. Inside a javascript
file (.js) outside of the page's folder I want to set its value according to the value of a listbox selected :
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
}
Code of AjaxTacheChangerNatureTache.php is :
<?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;
}
?>
So how to set the value of the field using JQuery
?