Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php HREF链接ajax post请求_Php_Ajax_Post_Request_Href - Fatal编程技术网

Php HREF链接ajax post请求

Php HREF链接ajax post请求,php,ajax,post,request,href,Php,Ajax,Post,Request,Href,为了拍摄,这是我的问题。我有一个通过ajax发送表单POST请求的脚本,但我的问题是我想在Href标记中完成它。以下是我的表格邮寄申请代码: <script type="text/javascript"> $(document).ready(function(){ $( ".searchForm" ).submit(function( event ) { event.preventDefault(); var invoiceNo=$(".in

为了拍摄,这是我的问题。我有一个通过ajax发送表单POST请求的脚本,但我的问题是我想在Href标记中完成它。以下是我的表格邮寄申请代码:

<script type="text/javascript">
$(document).ready(function(){
    $( ".searchForm" ).submit(function( event ) {
        event.preventDefault();

        var invoiceNo=$(".invoiceNo").val();
        var dataString = 'invoiceNo='+invoiceNo;

        $.ajax ({
            type: "POST",
            url: "<?php echo base_url(); ?>/billing/test",
            data: dataString,
            cache: false,
            success: function(html) {
                $(".particularList_output").html(html);
            } 
        });

    });
});
</script>

<form action="/" class="searchForm">
<input type="hidden" class="invoiceNo" value="thisIsMyValue">
<button id="xSmall" type="submit" class="btn btn-primary">Add Invoice</button>
</form>

$(文档).ready(函数(){
$(“.searchForm”).submit(函数(事件){
event.preventDefault();
var invoiceNo=$(“.invoiceNo”).val();
var dataString='invoiceNo='+invoiceNo;
$.ajax({
类型:“POST”,
url:“/billing/test”,
数据:dataString,
cache:false,
成功:函数(html){
$(“.specialList_output”).html(html);
} 
});
});
});
添加发票

执行以下操作:

<a href="<?php echo base_url();?>/billing/test" data-invoice="<?php echo $yourInvoiceNumber?>"> Add Invoice </a>

$('a').on('click', function(e){
    e.preventDefault();

    var $this = $(this);

    $.ajax({
        url: $this.data('href'),
        type: 'POST',
        data: 'invoiceNo='+$this.data('invoice'),
        cache: false,
        success: function(html) {
            $(".particularList_output").html(html);
        } 
    });
});

$('a')。在('click',函数(e)上{
e、 预防默认值();
var$this=$(this);
$.ajax({
url:$this.data('href'),
键入:“POST”,
数据:'invoiceNo='+$this.data('invoice'),
cache:false,
成功:函数(html){
$(“.specialList_output”).html(html);
} 
});
});

那么问题出在哪里?通过query-string创建包含所有附加数据的链接。它基本上是在表单标记中。我希望它在一个href链接