1

I'm using this code, to get values from a dynamic created <table>

$("#finalizar-pedido").click(function(){
            var id = [];
            var qtde = [];
            var makiRecheio = [];
            var makiComplemento = [];
            var makiCreme = [];
            var makiFinalizacao = [];
            var makiQtde = [];
            var i = 0;
            $("tr.row-item").each(function(i){
                var Linha = $(this);
                id[i] = Linha.find("td.pedido-nome input.id-item").val();
                qtde[i] = Linha.find("td.pedido-qtde").text();
            });
            $("tr.row-temaki").each(function(i){
                var Linha = $(this);
                makiRecheio[i] = Linha.find("td.pedido-nome input.mak-recheio").val();
                makiComplemento[i] = Linha.find("td.pedido-nome input.mak-complemento").val();
                makiCreme[i] = Linha.find("td.pedido-nome input.mak-creme").val();
                makiFinalizacao[i] = Linha.find("td.pedido-nome input.mak-finalizacao").val();
                makiQtde[i] = Linha.find("td.pedido-qtde").text();
            });
        });

This is working well, i made some tests and the values are OK. The Question is: How i can send the values to another page.php... I don't want to show the result in this same page, i need to send the values to another page just like de standard html form does. I tried to use the jQuery.post() method, but i dont know how to go to another page holding the values that i got from the table.

Sorry for the bad english, Thanks for your attention. :)

Shawii
  • 43
  • 6

2 Answers2

4

post method may have data. For example this code will send a post request to test.php with 2 parameters, name and time:

$.post( "test.php", { name: "John", time: "2pm" } );

Also you can send arrays:

$.post( "test.php", { "id": id , "qtde": qtde , ... } );

EDIT:

If you need to submit the post request and redirect to another page with the post request (No Ajax) you may make a dummy hidden form, put your data in it, make its method post and submit that form. Here you can find how to do it: jQuery post request (not AJAX)

Community
  • 1
  • 1
Saeed
  • 7,262
  • 14
  • 43
  • 63
  • I tried this, it works (sending the values) but i need to redirect the user to another page, and in this another page display and process de data i sended, like standard
    does.
    – Shawii Aug 14 '14 at 07:00
  • you mean you need to send a post request but not an ajax request? So look at these, it may help http://stackoverflow.com/questions/4583703/jquery-post-request-not-ajax – Saeed Aug 14 '14 at 07:05
1

I suggest you set a cookie in javascript, redirect the user to whatever page you like to show the data and then use PHP to read the cookie and process or display the data.

Read on setting javascript cookies on quirksmode or w3schools

also read on working with cookies in PHP on php.net

qsi
  • 683
  • 1
  • 7
  • 16