所以我想为jquery分配一个url参数值,但它不会接受它..
var product_id = '<?php echo $_GET["pID"]; ?>';
我的功能如下,包含文件准备就绪......刚发布相关内容
function sendOrderToServer() {
var order = $(".sortable_table").sortable("serialize");
var array_order = order.split("&");
var product_id = '<?php echo $_GET["pID"]; ?>';
alert(product_id);
for (var i=0;i<array_order.length;i++){
var id = array_order[i].split("=");
id = id[1];
var text_field_video = $("#products_video_sm_dynamic_"+ id).val();
var text_field_video_caption = $("#products_video_sm_dynamic_"+ id +"_caption").val();
var text_field_image = $("#products_image_sm_dynamic_"+ id).val();
var text_field_image_caption = $("#products_image_sm_dynamic_"+ id +"_caption").val();
var text_field_video_xl = $("#products_video_xl_dynamic_"+ id).val();
var text_field_video_xl_caption = $("#products_video_xl_dynamic_"+ id +"_caption").val();
var text_field_image_xl = $("#products_image_xl_dynamic_"+ id).val();
if(text_field_video != undefined){
var element = "products_video_sm_dynamic_" + id;
var position = i + 1;
}
if(text_field_image != undefined){
var element = "products_image_sm_dynamic_" + id ;
var position = i + 1;
}
if(text_field_video_xl != undefined){
var element2 = "products_video_xl_dynamic_" + id ;
var position = i + 1;
}
if(text_field_image_xl != undefined){
var element2 = "products_image_xl_dynamic_" + id ;
var position = i + 1;
}
//alert(element);
//alert("position is" + position);
$.ajax({
type:'POST',
url :'includes/insert_database.php',
data:{ position : position, element1:element , element2:element2},
success: function(result){
alert(result);
}
});
}
}
答案 0 :(得分:0)
请改为尝试:
var product_id = <?php echo json_encode($_GET['pID']); ?>