0

I want to send data to form like this:

<form id="dinero" action="" method="post">
<input id="user" type="text" placeholder="Usuario" maxlenght="10" name="user"></input>
<div class="select">
<select id="sel-dinero" name="dinero">
<option value="20000000"></option>
<option value="40000000"></option>
<option value="9000000"></option>
</select>
<i class="icon-caret-down icon-large"></i>
</div>
<input id="ver-dinero" class="boton" type="submit" value="¡Calcular!">
</input>
</form>

I tried with these:

Document docu = Jsoup.connect("http://www.comuniazo.com/comunio/dinero")
.data("user", "myUser")
.data("dinero", "20000000")
.post();

This is the ajax call that i see into the page:

$.ajax({
    url: 'ajax/dinero.php',
    type: 'POST',
    timeout: 300000,
    data: $('#dinero').serialize() + '&token=0ae4ba8a64da19b8ad00d8e605cfb604',
    error: function() {
         alert('Vaya, parece que está tardando más de lo normal. Puede que la web de Comunio esté sobrecargada. Inténtalo de nuevo más tarde.');
         $('.dinero').empty();
         $('#ver-dinero').removeClass('boton-loading');
         $('#ver-dinero').removeAttr('disabled');
    },
    success: function(response) {
         $('.dinero').html(response);
         $('#ver-dinero').removeClass('boton-loading');
         $('#ver-dinero').removeAttr('disabled');
    }
});

Please, can you help me? I can,t get the correct data.

Thanks.

EDIT: I test with these code too, but result is not good. Any ideas?

 Document docu = Jsoup.connect("http://www.comuniazo.com/comunio/dinero").get();
 docu.select("[name=user]").attr("value", "userName");

 FormElement formulario = (FormElement) docu.getElementById("dinero");

 Connection con = formulario.submit();
 Document docRespuesta = con.get();
  • Are you getting any errors? Is it even calling the ajax function? You need to give us more information. – Justin Wood Nov 18 '13 at 21:59
  • Doesn't return *anything*? Why aren't you sending a token? What happens if you use a tool like poster or curl to post? Why's the ajax for? – Dave Newton Nov 18 '13 at 21:59
  • **Justin**: I don,t get ant error but only the part of the html that i want to get, don,t appear. With jsoup i think ajax function will not have to call. **Dave**: I tried sending a token too but the result is the same. I don,t know poster or curl. That these tools are used? – NachoMacian Nov 30 '13 at 12:06

3 Answers3

0

I would try this one:

Document docu = Jsoup.connect("http://www.comuniazo.com/comunio/dinero")
.data("user", "myUser")
.data("dinero", "20000000")
.data("token", "0ae4ba8a64da19b8ad00d8e605cfb604")
.post();

If it does not work I would try to copy then later parse the actual token out from the script.

Peter Ambruzs
  • 7,763
  • 3
  • 30
  • 36
0

Or try this one:

Connection.Response res = Jsoup.connect("http://www.comuniazo.com/comunio/dinero")
.data("user", "myUser","dinero", "20000000")
.data("token", "0ae4ba8a64da19b8ad00d8e605cfb604")
.method(Method.POST)
.execute();

Document docu = res.parse();

Take a look at this article if you have to deal with token extraction from the cookie. jsoup posting and cookie

Community
  • 1
  • 1
Mehdi Karamosly
  • 5,388
  • 2
  • 32
  • 50
  • I can,t get the correct result sending token. The unique cookie is {PHPSESSID=0fmf9ljrraqchr770p9qcj00e5} and doesn,t works neither. Any suggestion? – NachoMacian Nov 30 '13 at 12:24
0

It seems that the php requested in the submit is http://www.comuniazo.com/ajax/dinero.php but if i put this url into de navigator it doesn,t return anything. If i try to access to http://www.comuniazo.com/ajax it shows me forbidden. Any ideas?

Thanks