Topic
1 reply Latest Post - ‏2013-03-14T13:49:11Z by babinag
SystemAdmin
SystemAdmin
648 Posts
ACCEPTED ANSWER

Pinned topic can we use ajax technologie when creating custom tools ?

‏2013-03-14T13:16:22Z |
Hello,

I'm trying to create a new custom tools and I'd like to know if it possible to use ajax technologie ?

I've tried this exemple but it doesn't works :

<%
function getPageUrl()
{
var url = getProductCenterURL() + "/utils/custom_page.jsp?script_id=" + request.script_id;
return url;
}
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Test validation AJAX</title>
<script type="text/javascript">
var xhr;
function getXhr()
{
var xhr = null;
// Réupération de l'objet XHR d'Internet Explorer anciennes
// versions si il existe
try {
xhr = new ActiveXObject('Msxml2.XMLHTTP');
alert("ActiveXObject('Msxml2.XMLHTTP') : " + xhr.responseText);
}
catch (e1)
{
// Réupération de l'objet XHR d'Internet Explorer anciennes
// versions si il existe
try {
xhr = new ActiveXObject('Microsoft.XMLHTTP');
alert("ActiveXObject('Microsoft.XMLHTTP') : " + xhr);
}
catch (e2)
{
// Réupération de l'objet XHR des navigateurs modernes
// (Firefox, Chrome, Safari...) si il existe
try {
xhr = new XMLHttpRequest();
alert("XMLHttpRequest : " + xhr);
}
catch (e3)
{
alert("AJAX n'est pas supporté par votre navigateur");
return false;
}
}
}
return xhr;
}

// Récupération de l'objet XMLHttpRequest
xhr = getXhr();
alert(xhr);
// On assigne une fonction qui, lorsque l'état de la requête change, va traiter le résultat
function gestionClic()
{
xhr = createRequestObject();
xhr.open('POST', '<%=getPageUrl() %>', true);
xhr.onreadystatechange = handleAJAXReturn;
xhr.send(null);
}

function handleAJAXReturn()
{
if (http.readyState == 4)
{
if (http.status == 200)
{
alert(http.responseText);
document.getElementById('resultat').innerHTML = http.responseText;
}
else
{
alert('Pas glop pas glop');
}
}
}
</script>
</head>
<body>

Cliquez ici !

 
<%=getPageUrl() %>
</body>
</html>
Updated on 2013-03-14T13:49:11Z at 2013-03-14T13:49:11Z by babinag
  • babinag
    babinag
    91 Posts
    ACCEPTED ANSWER

    Re: can we use ajax technologie when creating custom tools ?

    ‏2013-03-14T13:49:11Z  in response to SystemAdmin
    Hello, ichigo.

    Yes, you can use ajax and js with html in custom tools. We use some GWT custom pages = html+js+ajax(GWT-rpc).

    Check this thread bum