@nakov yes sir i run my project in browser. but your shared both url not working in my browser
@kanchan186 when I use yoursite.test that means that you should replace yoursite.test with however you access YOUR SITE in the browser.. just append /brand/Ajax/3 at the end..
This takes forever my friend.. I cannot stay here and help you the whole day long. I helped you with your initial question, and gave you 100 steps to reproduce the other problem... PLEASE spend some time debugging yourself if you want to learn to program..
@nakov extreamly sorry sir now i get that
after running url i got the values
{"6":"Bajaj","8":"Honda","9":"Piaggio"}
no error
@nakov sorry sir, actually sir i am frustrated with that same issue 4-5 days gone to do same work.
@kanchan186 so it seems like it does work.. Open the NETWORK tab in your browser, and make sure that the AJAX is calling the same URL, and it should work, and not get 404 instead.
@nakov ,sir in network tab no url shows but in console shows error
Failed to load resource: the server responded with a status of 404 (Not Found)
/brand/Ajax/3:1
@kanchan186 you should have the NETWORK tab opened, and then refresh the page and click on the checkbox in order for an error to appear.
I really don't know how else to help you my friend.. You should learn some basic debugging if you want to continue..
its get status 200 but no url /brand/Ajax/3:1 shows
@nakov it works, values are shows properly but checkboxes are not displayed

view
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<h4 class="card-title">Add Mechanic Brands</h4>
<h6 class="card-subtitle"></h6>
@if ($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<form class="m-t-40" method="post" action="{{url('/')}}/mechanic_brands/{{$mechanic->mechanic_id}}" enctype="multipart/form-data">
{{csrf_field()}}
<div class="form-group">
<h5>Segment<span class="text-danger">*</span></h5>
<div class="controls">
@foreach($segment as $sg)
<ul><li>
<input type="checkbox" value="{{$sg->segment_id }}" name="sg[{{$sg->segment_id }}]" id="{{$sg->segment_id }}" onclick="getBrand1(this.id)" class="test">
<label for="{{ $sg->segment_id }}">
<p>{{$sg->segment_name }}</p></label></li></ul>
@endforeach
</div>
</div>
<div class="controls">
<table id="brands">
<tr><td>
<input type="checkbox" name="brand_id"></td></tr>
</table>
</div>
<!-- <div class="form-group">
<h5>Choose Brands<span class="text-danger">*</span></h5>
<div class="controls" id="brands">
<table>
<tr><td>
<input type="checkbox" name="brand_id"></td></tr>
</div>
</div> -->
<div class="text-xs-right">
<button type="submit" class="btn btn-info">Submit</button>
<button type="reset" class="btn btn-inverse">Cancel</button>
</div>
</form>
</div>
</div>
</div>
</div>
script
<script type="text/javascript">
function getBrand1(id)
{
// alert('Choose brands!');
if(document.getElementById(id).checked)
{
$.ajax({
url: 'http://localhost/partsanalysis/public/brand/Ajax/'+id,
type: "GET",
dataType: "json",
error: function(data, errorThrown)
{
console.log('request failed :'+errorThrown);
},
success:function(result) {
console.log(result);
// alert(result);
$.each(result, function(index, value) {
//alert(value);
// $("#brands").html('<input type="checkbox" />'+value );
var markup = "<tr><td><input type='checkbox' name='brand_id'></td><td>" + value + "</td></tr>";
$("#brands").append(markup);
});
}
});
}
else
{
$("#brands").html("");
}
}
</script>
@kanchan186 do you use any library for the checkboxes? Make sure you disable any additional styling and see if they appear. Or use Inspect element on your browser to see if next to the text you can see a checkbox, anything else seems correct to me.
@kanchan186 as you've opened a new thread with a question that you already asked here, maybe you should consider accepting an answer that helped you here to solve your initial question..
Please or to participate in this conversation.