如何将Javascript变量传递给PHP&加载PHP [英] How do I pass the Javascript variable to PHP & Load that PHP

查看:63
本文介绍了如何将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


这篇关于如何将Javascript变量传递给PHP&amp;加载PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆