如何将Javascript变量传递给PHP&加载PHP
我要求将javascript对象传递给PHP文件&单击一个按钮时,将该文件加载到浏览器中。
index.html具有以下代码:
Hi,
I have a requirement to pass the javascript object to a PHP file & load that PHP file in browswer when a button is clicked.
index.html has the following code:
<button id="1a" type="button">Click here</button>
custom.js具有以下代码:
custom.js has the following code:
var testobject={'element1':1, 'element2':2}
$(document).ready(function() {
$("#123456").click(function(event){
$.post(
"test.php",
testobject
);
});
});
但我不知道写一个php文件来接收这些数据。
我也不是能够理解如何加载这个php文件
任何人都可以帮忙。
提前致谢
问候,
Ramakrishna
But I don't know to write a php file to receive this data.
Also I am not able to understand how to load this php file
Could anyone please help.
Thanks in advance.
Regards,
Ramakrishna
( document )。ready( function (){
(document).ready(function() {
( #123456)。click( function (event){
("#123456").click(function(event){
.post(
test.php ,
testobject
);
});
});
.post( "test.php", testobject ); }); });
但我不知道知道写一个php文件来接收这些数据。
我也无法理解如何加载这个php文件
任何人都可以请帮忙。
先谢谢。
问候,
Ramakrishna
But I don't know to write a php file to receive this data.
Also I am not able to understand how to load this php file
Could anyone please help.
Thanks in advance.
Regards,
Ramakrishna