Javascript 如果ajax状态返回true,则将表行状态更改为yes或no

Javascript 如果ajax状态返回true,则将表行状态更改为yes或no,javascript,php,jquery,mysql,ajax,Javascript,Php,Jquery,Mysql,Ajax,我想在ajax返回true时更改表行状态(是或否)。我的ajax请求工作正常,但已更改表的所有行状态 这是我的看法 @foreach($order_details as $key => $list) <tr> <td>{{$list->order_product_name}}</td> <td>{{ $size }}</td> <td>{{ $color }}</td&g

我想在ajax返回true时更改表行状态(是或否)。我的ajax请求工作正常,但已更改表的所有行状态

这是我的看法

@foreach($order_details as $key => $list)

  <tr>
     <td>{{$list->order_product_name}}</td>
     <td>{{ $size }}</td>
     <td>{{ $color }}</td>
     <td>{{$list->order_product_quantity}}</td>
     <td>{{ $list->tax_rate_percentage }}</td>
     <td>{{ $list->tax_amount }}</td>
     <td>{{ $list->order_product_unit_price }}</td>
     <td>{{ $list->order_product_total_price }}</td>
     <td><input type="text" data-order-id="{{ $list->order_id }}" class="product-check-physical"  name="product_id">
     </td>
     <td>
         <span class="done label label-success">Yes</span>
         <span class="not-done label label-danger">No</span>
     </td>
这是我的控制器

$product =\DB::table('order_details')
        ->where('order_id',$order_id)
        ->where('order_product_id',$product_id)
        ->first();
    if(!$product) {
        return response()->json(['status' => 0]);
    }
    return response()->json(['status' => $product]);

那么,
$('.done').show().closest('tr')
将导致显示包含
done
的类的所有元素。。。最后的
.closest('tr')
将不起任何作用-类似于
$('.not done').hide().closest('tr')
,将隐藏包含
not done
的类的所有元素。我已尝试删除了…closest('tr'),但它不起作用。我只想检查一下那排正在移动的不是答案。您需要弄清楚jQuery是如何工作的谢谢兄弟,我知道这个问题是当ajax返回true或false时,它影响了所有…完成或…未完成类,因为我调用的表行的名称相同,我无法弄清楚如何在每一行中放置不同的css类您不需要这样做。。。
on('keyup',函数(){
回调中的
this
将引用哪个
.product check physical
具有keybaord焦点,因此,知道您处于哪个输入中,您可以重写代码以更改相应的
。完成
/
。未完成
spanswell,
$('.done')。show()。最近('tr)
将导致显示包含
done
的类的所有元素…最后的
.closest('tr')
将不起任何作用-类似于
$('not done').hide().closest('tr')
,将隐藏包含
not done
的类的所有元素。我已经尝试删除了…closest('tr'))但它不起作用。我只想检查chckedRemoving的行不是答案。你需要弄清楚jQuery是如何工作的谢谢兄弟,我知道这个问题是当ajax返回true或false时,它影响了所有…完成或…未完成类,因为我调用的表行的名称相同,我无法弄清楚如何放置不同的css class在每一行中您不需要这样做,('keyup',函数(){
回调中的
this
将引用哪个
。product check physical
具有keybaord焦点,因此,知道您所处的输入,您可以重写代码以更改相应的
。完成了
/
。未完成
范围
$product =\DB::table('order_details')
        ->where('order_id',$order_id)
        ->where('order_product_id',$product_id)
        ->first();
    if(!$product) {
        return response()->json(['status' => 0]);
    }
    return response()->json(['status' => $product]);