Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/298.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/2/jquery/84.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 ajax问题-将everythink发送到链接栏,如GET选项_Php_Jquery_Ajax_Laravel_Forms - Fatal编程技术网

Php ajax问题-将everythink发送到链接栏,如GET选项

Php ajax问题-将everythink发送到链接栏,如GET选项,php,jquery,ajax,laravel,forms,Php,Jquery,Ajax,Laravel,Forms,ajax有一个问题,因为每次我想单击submit按钮时,都会在链接栏中显示everythink,如127.0.0.1:8000/?token[…]等,每个参数看起来都像html表单中的方法GET,但我没有任何方法。我认为我的代码甚至没有尝试执行路由,因为我对json或数据库没有任何问题 $('#saveBtn').on('click', function () { ajax: { url: "{{route('res.Add')}}", type:

ajax有一个问题,因为每次我想单击submit按钮时,都会在链接栏中显示everythink,如127.0.0.1:8000/?token[…]等,每个参数看起来都像html表单中的方法GET,但我没有任何方法。我认为我的代码甚至没有尝试执行路由,因为我对json或数据库没有任何问题

$('#saveBtn').on('click', function () {
        ajax: {
        url: "{{route('res.Add')}}",
        type: "post",
        dataType: 'json',
        delay: 250,
        data: function (params) {
        return {
            _token: CSRF_TOKEN,
            search: params.term // search term
        };
        },
        processResults: function (response) {
        return {
            results: response
        };
        },
        cache: true
    }
    });
///钮扣

<button type="submit" class="btn btn-primary" id="saveBtn">Add</button>

您必须首先防止单击事件<代码>$('#saveBtn')。在('click',函数(e){e.preventDefault();})上它仍然不执行路由链接中的任何代码使用浏览器开发控制台的“网络”选项卡检查ajax请求是否有效。如果没有,您只是将其定义为一个对象。@El_Vanja那么我该怎么办?你的意思是在那之前键入$.ajax?
Route::post("/res/Add", "ResController@addRes")->name('res.Add');