Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/2.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
Jquery 使用ajax从视图调用控制器_Jquery_Ajax - Fatal编程技术网

Jquery 使用ajax从视图调用控制器

Jquery 使用ajax从视图调用控制器,jquery,ajax,Jquery,Ajax,试图调用控制器并传递变量mat保存的数据。但它没有调用我的控制器功能。请帮助我,如何继续 $('#buttonadd').click(function () { var mat = $('#material_name').val(); $.ajax({ type: "post", url: $("#baseUrl").text()+"gc_purchase/add_material_info"+mat, success: func

试图调用控制器并传递变量
mat
保存的数据。但它没有调用我的控制器功能。请帮助我,如何继续

$('#buttonadd').click(function () {
    var mat = $('#material_name').val();
    $.ajax({
        type: "post",
        url: $("#baseUrl").text()+"gc_purchase/add_material_info"+mat,

        success: function (data) {
           $('#demo').html(data).show();
        },
        error: function (xhr, ajaxOptions, thrownError) {
            $('#material_name').text("Error encountered while saving the comments.");
        }
    });
});
试试这个:

$.ajax({
    url: '/Home/AddBooking',
    type: 'POST',
    datatype: 'json',
    data: { StartTime: StartTime, EndTime: EndTime, ProductId: ProductId },
            success: function (data) {
                location.reload();
            },
            error: function (jqXHR, textStatus, errorThrown) {
                 alert(errorThrown);
            }
        });
试试这个:

$.ajax({
    url: '/Home/AddBooking',
    type: 'POST',
    datatype: 'json',
    data: { StartTime: StartTime, EndTime: EndTime, ProductId: ProductId },
            success: function (data) {
                location.reload();
            },
            error: function (jqXHR, textStatus, errorThrown) {
                 alert(errorThrown);
            }
        });

这是我的控制器功能

公共功能添加材料信息() {


}这是我的控制器功能

公共功能添加材料信息() {


}

你在控制台上看到了什么?请添加
console.log($(“#baseUrl”).text()+“gc#u采购/添加#u物料信息”+mat)
到您的单击eventhandler以检查连接URL是否正确。显示控制器代码。您是否可以分享您的操作方法控制台上看到的内容?请添加
控制台.log($(“#baseUrl”).text()+“gc#u购买/添加#材料#u信息”+mat)
单击eventhandler以检查连接URL是否正确。显示控制器代码。请共享您的操作方法