jquery post不按我预期的方式工作

时间:2011-12-05 20:18:06

标签: php jquery absolute-path

我有这个jquery

$('.delete_step').live('click', function(e) {
     e.preventDefault();
     var delete_location = 'http//<?php echo $_SERVER["SERVER_NAME"]; ?>?route=module/cart/delete_builder_step';
     console.log(delete_location);
     var response = confirm("Are you sure you want to delete this step?");
    if(response){
       $.post( delete_location,     { step_id: $(this).attr("rel"), builder_id: "<?php print $builder_id; ?>" },
               function(result) {
                     // window.location.reload();
       });
     }
});

所有看起来都不错,然后在我的控制台中我得到了这个

 http//localhost?route=module/cart/delete_builder_step

这是正确的,但帖子正在这里

http://localhost/shop_pos/admin/http//localhost?route=module/cart/delete_builder_step

有没有办法使用jQuery帖子不是相对的,并使用我指定的完整网址

1 个答案:

答案 0 :(得分:6)

您错过了:中的http://

正确的版本:

var delete_location = 'http://<?php echo $_SERVER["SERVER_NAME"]; ?>?route=module/cart/delete_builder_step';