[英]need help to send variable from javascript to PHP
我嘗試將一些數據從html發送到處理頁面。 我想使用javascript。 JavaScript是:
$('#search').click(function(){
var param = serialize({
action:"searchmodelqp",
jhead:"aaData",
month:$("#search_month").val(),
year:$("#search_year").val(),
export:"excel"
});
$('#link2excel' ).replaceWith("<div id='link2excel'><a href='shows_merchan.php?" + param + "' target='_blank'>Export result as Excel file</a></div>");
});
我將其發送到此:
if(getVar('export')=='excel'){
$expexcel = 'excel';
} else {
$expexcel=0;
}
switch(getVar('action')){
case 'searchmodelqp':
modelqp(getVar('jhead'),getVar('month'),getVar('year'),getVar('export'));
break;
}
function modelqp($jsonhead,$month, $year,$export){
$Month = mysql_real_escape_string($month);
$Year = mysql_real_escape_string($year);
switch($jsonhead){
case 'aaData':
//i put mysql query here
break;
}
if($export==0) {
//do something
} else {
//do something
}
我該怎么做才能弄清楚?因為我對此沒有結果(腳本什么也不做)。
如下更改數據
data:action="searchmodelqp&jhead="aaData"&month=$("#search_month").val()&year=$("#search_year").val()&export="excel"
我在這一部分進行更改:
var param = jQuery.param({action:"searchmodelqp",jhead:"aaData",month:$("#search_month").val(),year:$("#search_year").val(),export:"excel"});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.