Monday, 15 March 2010

javascript - Access JSTL variable define in a jsp inside AJAX call -



javascript - Access JSTL variable define in a jsp inside AJAX call -

i got jsp file define jstl variable (form value) :

<c:set var="idetape" value="${etapeform.etape.idetape}" scope="page"/> <c:set var="idcontact" value="${etapeform.etape.idcontact}" scope="page"/> <c:set var="numerodossierfoa" value="${etapeform.dossier.numerodossier}" scope="page"/> <script type="text/javascript" src=myfile.js"/>"></script>

in myfile.js file, need utilize these variable got error tell me undefined.

i utilize these variables in ajax phone call :

var request = $.ajax({ type: "post", url: "/myurl/" + numerodossier + "/" + idcontact + "/" + idetape, cache: false });

where wrong ?

jsp variables cannot used within javascript file since jsp server side , js client side

try this:

<input id="idetape" value="${etapeform.etape.idetape}" type="hidden"/>

in js:

$("#idetape").val();

javascript jquery jsp

No comments:

Post a Comment