Update an asp section variable without refreshing the page

0

I'm breaking my head to try to solve this problem, but without success ...

I have a virtual store created for another programmer who disappeared. To vary code is undocumented.

To calculate the freight in the shopping cart it calls another asp file which in turn calls the webservice of the post office and returns the value in post to the shopping cart. This value is then loaded into a session variable.

Freight calculation form within the shopping cart:

<form method=post action=calcula_cep.asp>
<input name="met" id="met1" type="radio" value="PAC" />PAC (até 10 dias úteis)     
<input name="met" id="met2" type="radio" value="SEDEX" />SEDEX (até 4 dias úteis)
<input type=hidden name=peso value="<%=session("total_peso")%>">
<input type=text name="cep_1" id="cep_1" size=5 onkeyup="pulaCampo();" maxlength="5" class=campo value="<%=cepp1%>" readonly="readonly">-<input type=text name="cep_2" id="cep_2" size=3 maxlength="3" class=campo value="<%=cepp2%>" readonly="readonly">
<input type=submit name=submit value="Calcular" class="botao">
</form>

The file calcula_cep.asp calls the webservice of the mails and returns the variable Value_1 per post for the shopping cart:

if len(request("Valor_1")) > 0 then

   if len(session("log_cli"))>0 then
            Session("vTarifa") = Replace(request("Valor_1"),".",",")
     else
            Session("sTarifa") = replace(request("Valor_1"),".",",")
     end if

end if

What I am trying to do is an ajax request for calcula_cep.asp to update the value of Session ("vTarifa") and Session ("sTarifa"). My question is how to update the session and how to print this updated value in the cart, without updating the page (by javascript?).

    
asked by anonymous 27.03.2015 / 05:44

1 answer

2

Instead of using a submit button, create a common button and call a function containing ajax to call this page, a submit button will always reload it

<input type="button" onclick="calcula_cep()" value="calcular" class="botao">

Javascript

function calcula_cep() {
$.post("calcula_cep.asp",null,
     function(resposta){
       if (resposta){
          $("#controle_carrinho").html(resposta);
       }
  }
}

Vbscript

if len(request("Valor_1")) > 0 then

   if len(session("log_cli"))>0 then
        Session("vTarifa") = Replace(request("Valor_1"),".",",")
        response.write Session("vTarifa")
     else
        Session("sTarifa") = replace(request("Valor_1"),".",",")
        response.write Session("sTarifa")
     end if

end if

I hope I have helped

    
22.07.2015 / 17:17