Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

248
Visualizações
Javascript How to hide a function from my web app (by using php?)

I am making a web app that has typical javascript structure below. I must hide at least a function or some formulas from the public code because someone can save the page on his computer without paying for the web app membership. I am not sure how to do that.

"edit" I found the answer and is in the following snippet. My problem now is how to pass the data outside the $.post( )?

   function analysis(){
          var  L = "sting";
          var  w   = JSON.stringify(w);
          var  counter = "sting";
  $.post('../php/solver2.php',{L : L , w : w , counter:counter },
 function(data){  jdata  = JSON.parse(data); });
     
            var jdata  = JSON.parse(tempJdata);
            var x          = jdata.x;
            var v          = jdata.v;
       
       return [x v];
 }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"> </script>

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

You can't stop someone to download your client side script code.

Check this How do I hide javascript code in a webpage?

And i can check every client side code with the browser developer tools.

Edit: You mean this:

How do I pass JavaScript to PHP?

Sending a JavaScript array to PHP via POST

Pass Javascript Array -> PHP

This are your HTTP request methods(check for browser compatibility):

HTTP request methods

Every operation on the server-side is hidden(on a normal way without bugs or something else) and the result you send to the client is public.

over 4 years ago · Santiago Trujillo Relatório

0

Use JSON.stringify() on your array and use AJAX to send it to your php script.

On php side, you can json_decode() that same array and work with it.

You could protect that PHP script with sessions, and return an error if one is not allowed to access it.

over 4 years ago · Santiago Trujillo Relatório

0

I found the answer sending multiple arrays to php process them and return processed arrays.

          var  L = "sting";
          var  w   = JSON.stringify(w);
          var  counter = "sting";
  $.post('../php/solver2.php',{L : L , w : w , counter:counter },
 function(data){  var jdata  = JSON.parse(data);
                  var x          = jdata.x;
                  var v          = jdata.v;});
     

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda