jquery ajax请求后模式不工作
当我点击class.btn edit按钮时,会出现模式,但当我 如果我单击模式的按钮,则在此之后提交ajax请求 莫代尔没有出现。我需要刷新页面,它才能再次工作。 控制台日志错误:未捕获的TypeError:$(…)。模式不是函数jquery ajax请求后模式不工作,jquery,twitter-bootstrap,Jquery,Twitter Bootstrap,当我点击class.btn edit按钮时,会出现模式,但当我 如果我单击模式的按钮,则在此之后提交ajax请求 莫代尔没有出现。我需要刷新页面,它才能再次工作。 控制台日志错误:未捕获的TypeError:$(…)。模式不是函数 $(".btn-edit").click(function () { $('#edit-profile').modal('toggle'); $(".update-form").submit(function(s){ s.pre
$(".btn-edit").click(function () {
$('#edit-profile').modal('toggle');
$(".update-form").submit(function(s){
s.preventDefault();
var website_name = $('input[name=website_name]').val();
var website_url = $('input[name=website_url]').val();
var type = $('#type option:selected').val();
var category = $('#category option:selected').val();
var sells = $('input[name=sells]').val();
var location = $('input[name=location]').val();
var payment = $('input[name=payment]').val();
var description = $("textarea#message").val();
$('#edit-profile').modal('hide');
setTimeout(function(){
$.ajax({
type: "POST",
url: "advertiser/update",
data: {
_token: token, website_name: website_name, website_url: website_url, type: type, category: category, sells: sells, location: location, payment: payment, description: description
},
success: function(data) {
$('.wrapper').html(data);
},
error: function(data) {
}
})
},1000);
});
});
HTML
编辑
X
编辑店铺信息
{!!Form::open(数组('url'=>'advertiser/update','files'=>true,'class'=>'update-Form','id'=>'update-Form','method'=>'POST'))
@foreach($shop作为$shops)
店名
商店网址
商店类型
{!!\App\Library\Category::type($shops->type)
网上商店
网上市场
集团与交易网站
社交商店
商店类别
{!!\App\Library\Category::Category($shops->Category)
电子和小工具
服装及配件
家庭与办公室
玩具和婴儿用品
健康与体育
卖
立足
付款方式
描述
{!!$shops->description!!}
您已达到限制
改变
@endforeach
{!!Form::close()!!}
我认为AJAX函数会覆盖click处理程序绑定到的元素。请包含您的HTML代码。@showdev感谢您的回复这里是我的HTML,我看到“此页面已被删除!”。@showdev抱歉@showdev请帮助我:)
<button class="btn btn-info pull-right btn-edit">Edit</button>
<div class="modal fade" class="profile" id="edit-profile" tabindex="-1" role="dialog" aria-labelledby="modalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" ><span aria-hidden="true">X</span><span class="sr-only"></span></button>
<h3 class="modal-title" id="lineModalLabel">Edit Shop Information</h3>
</div>
<div class="modal-body">
{!! Form::open(array('url'=>'advertiser/update','files'=>true , 'class'=>'update-form','id'=>'update-form','method'=>'POST')) !!}
@foreach($shop as $shops)
<div class="form-group col-lg-6">
<label>Shop Name</label>
<input type="textbox" name="website_name" class="form-control" id="" value="{!! $shops->website_name !!}">
</div>
<div class="form-group col-lg-6">
<label>Shop URL</label>
<input type="textbox" name="website_url" class="form-control" id="" value="{!! $shops->website_url !!}" placeholder="www.shop.com or www.facebook.com/shopname">
</div>
<div class="form-group col-lg-6">
<label for="type">Shop Type</label>
<select class="form-control" id="type" name="type">
<option value="{!! $shops->type !!}">{!! \App\Library\Category::type($shops->type) !!}</option>
<option value="Online Shops">Online Shop</option>
<option value="Online Marketplaces">Online Marketplaces</option>
<option value="Group & Deal Website">Group & Deal Website</option>
<option value="Social Shops"> Social Shops</option>
</select>
</div>
<div class="form-group col-lg-6">
<label for="category">Shop Category</label>
<select class="form-control" id="category" name="category">
<option value="{!! $shops->category !!}">{!! \App\Library\Category::category($shops->category) !!}</option>
<option value="Electronic & Gadgets">Electronic & Gadgets</option>
<option value="Apparel & Accessory">Apparel & Accessory</option>
<option value="Home & Office">Home & Office</option>
<option value="Toy & Baby Stuff">Toy & Baby Stuff</option>
<option value="Health & Sports">Health & Sports</option>
</select>
</div>
<div class="form-group col-lg-6">
<label>Sells</label>
<input type="textbox" name="sells" class="form-control" id="" value="{!! $shops->sells !!}" placeholder="">
</div>
<div class="form-group col-lg-6">
<label>Base In</label>
<input type="textbox" name="location" class="form-control" id="" value="{!! $shops->location !!}" placeholder="location">
</div>
<div class="form-group col-lg-6">
<label>Payment Method</label>
<input type="textbox" name="payment" class="form-control" id="" value="{!! $shops->payment !!}" placeholder="example: paypal">
</div>
<div class="form-group col-lg-12">
<label>Description</label>
<textarea maxlength="600" class="form-control description" id="message" name="description" placeholder="Description" rows="7">{!! $shops->description !!}</textarea>
<span class="help-block"><p id="characterLeft_editshop" class="help-block">You have reached the limit</p></span>
</div>
<button type="submit" class="btn btn-success btn-hover-green" id="edit_submit" style="width: 100%;" >Make Changes</button>
@endforeach
{!! Form::close() !!}
</div>
</div>
</div>
</div>