[英]Send javascript var values to php page (not ajax)
I'm using this code, to get values from a dynamic created <table>
我正在使用此代码,以从动态创建的<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. 问题是:如何将值发送到另一个page.php ...我不想在同一页面中显示结果,我需要像标准html表单一样将值发送到另一个页面。 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. 我试图使用jQuery.post()方法,但是我不知道如何转到保存从表中获取的值的另一页。
Sorry for the bad english, Thanks for your attention. 对不起,英语不好,谢谢您的关注。 :) :)
post
method may have data. post
方法可能有数据。 For example this code will send a post request to test.php
with 2 parameters, name and time: 例如,此代码将向test.php
发送一个发布请求,其中包含2个参数,名称和时间:
$.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. 如果您需要提交发布请求并使用该发布请求(No Ajax)重定向到另一个页面,则可以制作一个虚拟的隐藏表单,将数据放入其中,将其方法post
并提交该表单。 Here you can find how to do it: jQuery post request (not AJAX) 在这里您可以找到方法: jQuery发布请求(不是AJAX)
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. 我建议您在javascript中设置cookie,将用户重定向到您想要显示数据的任何页面,然后使用PHP读取cookie并处理或显示数据。
Read on setting javascript cookies on quirksmode or w3schools 阅读有关在quirksmode或w3schools上设置JavaScript cookie的内容
also read on working with cookies in PHP on php.net 另请阅读在php.net上使用PHP使用Cookie的内容
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.