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. :)

2 Answers 2

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)

Sign up to request clarification or add additional context in comments.

2 Comments

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 <form action="test.php" method="post"> does.
you mean you need to send a post request but not an ajax request? So look at these, it may help stackoverflow.com/questions/4583703/…
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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.