I have some trouble using ajax with JSF. Indeed I'm trying what I'm to do is very simple, but I can't figure it out. I have method that return a String, and I want to print this String only when I click on the button. This method takes 2 argument that I want to pass to the method with 2 inputBox. Here the code I provided so far but it's not finished and I don't if I'm doing it well :
<h:commandButton id="submit" value="Submit"> 
            <f:ajax event="click" />
        </h:commandButton>
        <h:outputText id="result" value="#{cSVobjectCtrl.getJson(48.866667, 2.33333)}" />
The problem with this code is that I get directly the string before I click on the button. What should I change to make this code work the way I want.
EDIT 1 :
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
      xmlns:f="http://xmlns.jcp.org/jsf/core">
    <h:head>
        <title>JsonValue</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
       <script>
         var show = function(){
         document.getElementById('result').style.display = 'block';
        }
        </script>
    </h:head>
    <h:form>
        <h:commandButton id="submit" value="Submit" onclick="show();" > 
     <f:ajax event="click" render="result"/>
</h:commandButton>
<h:outputText id="result" value="#{cSVobjectCtrl.getJson(48.866667, 2.33333)}" 
              style="display:'none'"/>
    </h:form>
</html>
But the problem still remains. The String is displayed before I click on the button.
 
     
    