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/75.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 jQuery提交按钮没有';我不能负重工作_Php_Jquery_Ajax_Forms_Submit - Fatal编程技术网

Php jQuery提交按钮没有';我不能负重工作

Php jQuery提交按钮没有';我不能负重工作,php,jquery,ajax,forms,submit,Php,Jquery,Ajax,Forms,Submit,当我加载页面时,一切正常,表单被提交,我得到了正确的回复。。但是当我用jQuery函数加载页面时,表单没有提交!我从Ajax函数中什么也得不到!!有什么帮助吗 这是我的HTML: <div class="container"> <div class="row"> <h4>Manage Contents</h4>

当我加载页面时,一切正常,表单被提交,我得到了正确的回复。。但是当我用jQuery函数加载页面时,表单没有提交!我从Ajax函数中什么也得不到!!有什么帮助吗

这是我的HTML:

                   <div class="container">
                        <div class="row">
                            <h4>Manage Contents</h4>
                            <div class="table-responsive table3">
                              <table class="table table-bordered">
                                <thead>
                                  <tr>
                                    <th>#</th>
                                    <th>Content</th>
                                    <th>Owner</th>
                                    <th>Created Date</th>
                                    <th>Project</th>
                                    <th>Priorty</th>
                                    <th>Options</th>
                                  </tr>
                                </thead>
                                <tbody>
                                @if ($availabe >= 1 )
                                  <?php $i =1; ?>
                                  @foreach ($avashown as $key)

                              <?php //this is edit content form?>
                              @if(isset($index) && $index == $i && isset($editid) && isset($idexist) && $idexist == $key->id)
                                <tr>
                                <form id="edit-content-form" action="/testajax" method="POST">
                                    <td>{{ $i }}</td>
                                    <td hidden="hidden">{{ csrf_field() }}</td>
                                    <td hidden="hidden"><input type="hidden" name="id" value="{{ $editid }}"></td>
                                    <td hidden="hidden"><input type="hidden" name="index" value="{{ $index }}"></td>
                                    <td colspan="3">
                                      <div class="control-group" id="inputField1">
                                        <input class="form-control" type="text" name="content" value="{{ $key->content }}">
                                        <span class="help-block hideme" id="help-block1"></span>
                                      </div>
                                    </td>                                    
                                      <td colspan="1">
                                        <div class="control-group" id="inputField2">
                                          <select class="form-control" name="project">
                                            @foreach ($projects as $project)
                                              <option value="{{ $project->id }}">{{ $project->projectname }}</option>
                                              @endforeach
                                          </select>
                                          <span class="help-block hideme" id="help-block2"></span>
                                        </div>
                                      </td>
                                      <td colspan="1">
                                        <div class="control-group" id="inputField3">
                                          <select class="form-control" name="priority">
                                              @foreach ($priorities as $priority)
                                              <option value="{{ $priority->id }}">{{ $priority->value }}</option>
                                              @endforeach
                                          </select>
                                          <span class="help-block hideme" id="help-block3"></span>
                                        </div>
                                      </td>
                                      <td>
                                        <input type="submit" id="submitForm" name="submit" value="Done">
                                      </td>
                                    </form>
                                </tr>
                              <?php $i++;//i have to increase it here again?>
                              @else
                              <tr>
                              <td class="hidden"></td>
                                <td>{{ $i }}</td>
                                <td>{{ $key->content }}</td>
                                <?php $firstname = \App\User::find($key->owner_id);?>
                                <td>{{ ucfirst($firstname->firstname) }}</td>
                                <td>{{ $key->created_at }}</td>
                                <?php $projectname = \App\Project::find($key->project_id);?>
                                <td>{{ $projectname-> projectname }}</td>
                                <?php $priorty = \App\Priority::find($key->priority_id);?>
                                <td><span class ="label label-{{ $priorty->name }}">{{ $priorty->value }}<span></td>

                                <td>
                                  <span class="glyphicon glyphicon-trash" data-toggle="tooltip" data-placement="bottom" title="Delete" onclick="ContentStatus('delete/ajax/{{ $key->id }}')"></span><span>&nbsp;</span>

                                  <span id="editContentGlyph" data-toggle="tooltip" data-placement="bottom" title="Edit" class="glyphicon glyphicon-cog" onclick="editContent({{ $i }},{{ $key->id }})"></span>

                                </td>
                              <?php $i++; ?>
                              </tr>
                              @endif
                                @endforeach
                              @else
                                  <tr>
                                      <td>0</td>
                                      <td colspan="6">Let's Work and Add some Contents! <a href="/new_content" data-toggle="tooltip" data-placement="bottom" title="Create">Create</a></td>
                                  </tr>
                            @endif
                          </tbody>
                        </table>
                      </div>
                    </div>
                </div>`

管理内容
#
内容
所有者
创建日期
项目
优先权
选择权
@如果($available>=1)
@foreach($显示为$key)
@if(isset($index)&&$index=$i&&isset($editid)&&isset($idexist)&&&$idexist==$key->id)
{{$i}
{{csrf_field()}}
@foreach($项目作为$项目)
{{$project->projectname}
@endforeach
@foreach($priority作为$priority)
{{$priority->value}
@endforeach
@否则
{{$i}
{{$key->content}
{{ucfirst($firstname->firstname)}
{{$key->created_at}
{{$projectname->projectname}
{{$priorty->value}
@恩迪夫
@endforeach
@否则
0
让我们工作并添加一些内容!
@恩迪夫
`
这是我的脚本文件:

function editContent(index,id){

    var place  = ".table3 tbody tr:nth-child("+index+") " ;
    var place  = "#alltables" ;
    var des    = place+" > *";

$(document).ready(function(){
    $( place ).load("http://localhost:8000/manage_contents/"+index+"/"+id+" "+des, function(){
    });
});
}


$(document).ready(function(){

$(function(){
    $('#edit-content-form').on('submit',function(e){
        $.ajaxSetup({
            header:$('meta[name="_token"]').attr('content')
        })
        e.preventDefault(e);

            $.ajax({

            type:"PUT",
            url:'http://localhost:8000/testajax',
            data:$(this).serialize(),
            dataType: 'json', 
            success: function(data){
                $("#alerts").html(data.responseText);

                if (data.updated) {
                    var place  = ".table3 tbody tr:nth-child("+data.index+") " ;
                    var des    = place+" > *";
                    $( place ).load("http://localhost:8000/manage_contents/ "+des, function(){
                    });
                }

            },
            error: function(data,xhr, ajaxOptions, thrownError){
                $.each(data.responseJSON, function(){
                    var i = 1;
                    $.each(this, function(index,error) {
                        $("#inputField"+i).addClass(" has-error");
                        $("#help-block"+i).removeClass(" hideme");
                        $("#help-block"+i).html("<strong>"+error+"</strong>");
                        i++;
                    });
                });

            },
        })
    });
});




});
函数编辑内容(索引,id){
var place=“.table3 tbody tr:n子项(“+index+”);
var place=“#所有表格”;
var des=地点+“>*”;
$(文档).ready(函数(){
$(位置)。加载(“http://localhost:8000/manage_contents/“+index+”/“+id+”+des,函数(){
});
});
}
$(文档).ready(函数(){
$(函数(){
$(“#编辑内容表单”)。关于('submit',函数(e){
$.ajaxSetup({
标题:$('meta[name=“\u-token”]”)。attr('content'))
})
e、 防止违约(e);
$.ajax({
键入:“放置”,
网址:'http://localhost:8000/testajax',
数据:$(this).serialize(),
数据类型:“json”,
成功:功能(数据){
$(“#警报”).html(data.responseText);
如果(数据更新){
var place=“.table3 tbody tr:n子项(“+data.index+”);
var des=地点+“>*”;
$(位置)。加载(“http://localhost:8000/manage_contents/ “+des,函数(){
});
}
},
错误:函数(数据、xhr、ajaxOptions、thrownError){
$.each(data.responseJSON,function(){
var i=1;
$.each(此,函数(索引,错误){
$(“#inputField”+i).addClass(“有错误”);
$(“#帮助阻止”+i).removeClass(“hideme”);
$(“#帮助块”+i).html(“”+error+“”);
i++;
});
});
},
})
});
});
});

`

我怀疑这是由于您的HTML
表单通过
ajax
加载,而在此之前只有您的
$(文档)。
$(function(){
    $(document).on('submit','#edit-content-form',function(e){

     // your existing code goes here

    });
});