How to return data from ajax to select tag





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







0















I have two select tag in auth.register.



<div class = "form-group col-md-6 col-sm-6">
<label for="years">Name of Course*</label>
<select class="form-control input-sm required" id="courses_name" name="alumni_course">
<option value="">-- Select Any one --</option>
@foreach($coursename as $coursenames)
<option value="{{ $coursenames->id.','.$coursenames->coursename }}" >{{ $coursenames->coursename }}</option>
@endforeach
</select>
</div>

<div class = "form-group col-md-6 col-sm-6" id="dvPassport" style="display:none">
<label for="years">Name of Branch*</label>

<select class="form-control input-sm required" id="branch_name" name="alumni_branch">
@if(isset($branchname))
@foreach($branchname as $branchnames)
<option value="{{ $branchnames->id }}" >{{ $branchnames->branchname }}</option>
@endforeach
@endif
</select>
</div>


If from Name of Course option, any one select B.E./B.TECH. or DIPLOMA, then Name of Branch will be show and data will be related B.E./B.TECH. or DIPLOMA.



MY ajax in same page:



<script type="text/javascript">
$(document).ready(function() {
$("#courses_name").change(function() {

var courses_name1 = $("#courses_name").val();
var courses_name2 = courses_name1.split(",");
var id = courses_name2[0];
var courses_name2 = courses_name2[1];
if (courses_name2 == 'B.E./B.TECH.' || courses_name2 == 'DIPLOMA') {
$("#dvPassport").show();
$.ajax({
type: "GET",
url: "findbranch",
data: {
'id': id
},
}).done(function(data) {
$("#branch_name").html(data.html);
//console.log(data);
});
} else {
$("#dvPassport").hide();
}
});
});
</script>


Route is:



Route::get('findbranch','AuthRegisterController@findbranch');


Controller is:



public function findbranch(Request $request)
{
$branchname = branchname::where('course_id', $request->id)->get();
$html = view('auth.register')->with(compact('branchname'))->render();
return response()->json(['success' => true, 'html' => $html]);
}


But data is not showing in Name of Branch.










share|improve this question

























  • In ajax url change it to '{{url("findbranch")}}' and see network tab, does it execute the request?

    – Adis
    Nov 23 '18 at 11:29











  • paste the auth.register contents please. update it in question.

    – Omar Abdullah
    Nov 23 '18 at 11:30













  • auth.register is above select tag and ajax

    – user3526766
    Nov 23 '18 at 11:32











  • Is the ajax executed? Check your network tab and see what it returns.

    – Adis
    Nov 23 '18 at 11:34











  • GET localhost/millennium_alumni_laravel/findbranch?id=7 500 (Internal Server Error)

    – user3526766
    Nov 23 '18 at 11:36


















0















I have two select tag in auth.register.



<div class = "form-group col-md-6 col-sm-6">
<label for="years">Name of Course*</label>
<select class="form-control input-sm required" id="courses_name" name="alumni_course">
<option value="">-- Select Any one --</option>
@foreach($coursename as $coursenames)
<option value="{{ $coursenames->id.','.$coursenames->coursename }}" >{{ $coursenames->coursename }}</option>
@endforeach
</select>
</div>

<div class = "form-group col-md-6 col-sm-6" id="dvPassport" style="display:none">
<label for="years">Name of Branch*</label>

<select class="form-control input-sm required" id="branch_name" name="alumni_branch">
@if(isset($branchname))
@foreach($branchname as $branchnames)
<option value="{{ $branchnames->id }}" >{{ $branchnames->branchname }}</option>
@endforeach
@endif
</select>
</div>


If from Name of Course option, any one select B.E./B.TECH. or DIPLOMA, then Name of Branch will be show and data will be related B.E./B.TECH. or DIPLOMA.



MY ajax in same page:



<script type="text/javascript">
$(document).ready(function() {
$("#courses_name").change(function() {

var courses_name1 = $("#courses_name").val();
var courses_name2 = courses_name1.split(",");
var id = courses_name2[0];
var courses_name2 = courses_name2[1];
if (courses_name2 == 'B.E./B.TECH.' || courses_name2 == 'DIPLOMA') {
$("#dvPassport").show();
$.ajax({
type: "GET",
url: "findbranch",
data: {
'id': id
},
}).done(function(data) {
$("#branch_name").html(data.html);
//console.log(data);
});
} else {
$("#dvPassport").hide();
}
});
});
</script>


Route is:



Route::get('findbranch','AuthRegisterController@findbranch');


Controller is:



public function findbranch(Request $request)
{
$branchname = branchname::where('course_id', $request->id)->get();
$html = view('auth.register')->with(compact('branchname'))->render();
return response()->json(['success' => true, 'html' => $html]);
}


But data is not showing in Name of Branch.










share|improve this question

























  • In ajax url change it to '{{url("findbranch")}}' and see network tab, does it execute the request?

    – Adis
    Nov 23 '18 at 11:29











  • paste the auth.register contents please. update it in question.

    – Omar Abdullah
    Nov 23 '18 at 11:30













  • auth.register is above select tag and ajax

    – user3526766
    Nov 23 '18 at 11:32











  • Is the ajax executed? Check your network tab and see what it returns.

    – Adis
    Nov 23 '18 at 11:34











  • GET localhost/millennium_alumni_laravel/findbranch?id=7 500 (Internal Server Error)

    – user3526766
    Nov 23 '18 at 11:36














0












0








0








I have two select tag in auth.register.



<div class = "form-group col-md-6 col-sm-6">
<label for="years">Name of Course*</label>
<select class="form-control input-sm required" id="courses_name" name="alumni_course">
<option value="">-- Select Any one --</option>
@foreach($coursename as $coursenames)
<option value="{{ $coursenames->id.','.$coursenames->coursename }}" >{{ $coursenames->coursename }}</option>
@endforeach
</select>
</div>

<div class = "form-group col-md-6 col-sm-6" id="dvPassport" style="display:none">
<label for="years">Name of Branch*</label>

<select class="form-control input-sm required" id="branch_name" name="alumni_branch">
@if(isset($branchname))
@foreach($branchname as $branchnames)
<option value="{{ $branchnames->id }}" >{{ $branchnames->branchname }}</option>
@endforeach
@endif
</select>
</div>


If from Name of Course option, any one select B.E./B.TECH. or DIPLOMA, then Name of Branch will be show and data will be related B.E./B.TECH. or DIPLOMA.



MY ajax in same page:



<script type="text/javascript">
$(document).ready(function() {
$("#courses_name").change(function() {

var courses_name1 = $("#courses_name").val();
var courses_name2 = courses_name1.split(",");
var id = courses_name2[0];
var courses_name2 = courses_name2[1];
if (courses_name2 == 'B.E./B.TECH.' || courses_name2 == 'DIPLOMA') {
$("#dvPassport").show();
$.ajax({
type: "GET",
url: "findbranch",
data: {
'id': id
},
}).done(function(data) {
$("#branch_name").html(data.html);
//console.log(data);
});
} else {
$("#dvPassport").hide();
}
});
});
</script>


Route is:



Route::get('findbranch','AuthRegisterController@findbranch');


Controller is:



public function findbranch(Request $request)
{
$branchname = branchname::where('course_id', $request->id)->get();
$html = view('auth.register')->with(compact('branchname'))->render();
return response()->json(['success' => true, 'html' => $html]);
}


But data is not showing in Name of Branch.










share|improve this question
















I have two select tag in auth.register.



<div class = "form-group col-md-6 col-sm-6">
<label for="years">Name of Course*</label>
<select class="form-control input-sm required" id="courses_name" name="alumni_course">
<option value="">-- Select Any one --</option>
@foreach($coursename as $coursenames)
<option value="{{ $coursenames->id.','.$coursenames->coursename }}" >{{ $coursenames->coursename }}</option>
@endforeach
</select>
</div>

<div class = "form-group col-md-6 col-sm-6" id="dvPassport" style="display:none">
<label for="years">Name of Branch*</label>

<select class="form-control input-sm required" id="branch_name" name="alumni_branch">
@if(isset($branchname))
@foreach($branchname as $branchnames)
<option value="{{ $branchnames->id }}" >{{ $branchnames->branchname }}</option>
@endforeach
@endif
</select>
</div>


If from Name of Course option, any one select B.E./B.TECH. or DIPLOMA, then Name of Branch will be show and data will be related B.E./B.TECH. or DIPLOMA.



MY ajax in same page:



<script type="text/javascript">
$(document).ready(function() {
$("#courses_name").change(function() {

var courses_name1 = $("#courses_name").val();
var courses_name2 = courses_name1.split(",");
var id = courses_name2[0];
var courses_name2 = courses_name2[1];
if (courses_name2 == 'B.E./B.TECH.' || courses_name2 == 'DIPLOMA') {
$("#dvPassport").show();
$.ajax({
type: "GET",
url: "findbranch",
data: {
'id': id
},
}).done(function(data) {
$("#branch_name").html(data.html);
//console.log(data);
});
} else {
$("#dvPassport").hide();
}
});
});
</script>


Route is:



Route::get('findbranch','AuthRegisterController@findbranch');


Controller is:



public function findbranch(Request $request)
{
$branchname = branchname::where('course_id', $request->id)->get();
$html = view('auth.register')->with(compact('branchname'))->render();
return response()->json(['success' => true, 'html' => $html]);
}


But data is not showing in Name of Branch.







laravel laravel-5






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 11:32







user3526766

















asked Nov 23 '18 at 11:21









user3526766user3526766

638




638













  • In ajax url change it to '{{url("findbranch")}}' and see network tab, does it execute the request?

    – Adis
    Nov 23 '18 at 11:29











  • paste the auth.register contents please. update it in question.

    – Omar Abdullah
    Nov 23 '18 at 11:30













  • auth.register is above select tag and ajax

    – user3526766
    Nov 23 '18 at 11:32











  • Is the ajax executed? Check your network tab and see what it returns.

    – Adis
    Nov 23 '18 at 11:34











  • GET localhost/millennium_alumni_laravel/findbranch?id=7 500 (Internal Server Error)

    – user3526766
    Nov 23 '18 at 11:36



















  • In ajax url change it to '{{url("findbranch")}}' and see network tab, does it execute the request?

    – Adis
    Nov 23 '18 at 11:29











  • paste the auth.register contents please. update it in question.

    – Omar Abdullah
    Nov 23 '18 at 11:30













  • auth.register is above select tag and ajax

    – user3526766
    Nov 23 '18 at 11:32











  • Is the ajax executed? Check your network tab and see what it returns.

    – Adis
    Nov 23 '18 at 11:34











  • GET localhost/millennium_alumni_laravel/findbranch?id=7 500 (Internal Server Error)

    – user3526766
    Nov 23 '18 at 11:36

















In ajax url change it to '{{url("findbranch")}}' and see network tab, does it execute the request?

– Adis
Nov 23 '18 at 11:29





In ajax url change it to '{{url("findbranch")}}' and see network tab, does it execute the request?

– Adis
Nov 23 '18 at 11:29













paste the auth.register contents please. update it in question.

– Omar Abdullah
Nov 23 '18 at 11:30







paste the auth.register contents please. update it in question.

– Omar Abdullah
Nov 23 '18 at 11:30















auth.register is above select tag and ajax

– user3526766
Nov 23 '18 at 11:32





auth.register is above select tag and ajax

– user3526766
Nov 23 '18 at 11:32













Is the ajax executed? Check your network tab and see what it returns.

– Adis
Nov 23 '18 at 11:34





Is the ajax executed? Check your network tab and see what it returns.

– Adis
Nov 23 '18 at 11:34













GET localhost/millennium_alumni_laravel/findbranch?id=7 500 (Internal Server Error)

– user3526766
Nov 23 '18 at 11:36





GET localhost/millennium_alumni_laravel/findbranch?id=7 500 (Internal Server Error)

– user3526766
Nov 23 '18 at 11:36












3 Answers
3






active

oldest

votes


















1














Use



$html = view('auth.register')->with(compact('branchname'))->render();


This will solve your problem.



Edit :



Problem is with your $("#branch_name").html(data.html);



it should be $("#branch_name").html(data);






share|improve this answer


























  • Sorry, But again same error.

    – user3526766
    Nov 23 '18 at 11:58











  • GET localhost/millennium_alumni_laravel/findbranch?id=7 500 (Internal Server Error)

    – user3526766
    Nov 23 '18 at 11:59











  • If I run localhost/millennium_alumni_laravel/findbranch?id=7 direct then error: (2/2) ErrorException Undefined variable: collegename (View: F:xampphtdocsmillennium_alumni_laravelresourcesviewsauthregister.blade.php)

    – user3526766
    Nov 23 '18 at 12:00











  • So, it means there is a variable you are using inside view named collegename which is not passed to it.

    – Omar Abdullah
    Nov 23 '18 at 12:01











  • Hold on i don't see any collegename in code you posted in question. Do php artisan view:clear to clean you cached view

    – Omar Abdullah
    Nov 23 '18 at 12:03



















0














You can try this code:



$.ajax({



        url: base_url + '/findbranch',
type: "GET",
data: {'id': id},
dataType: 'json',
success: function(data) {

$("#branch_name").html(data.html);
},





share|improve this answer
























  • Sorry. It is also not working

    – user3526766
    Nov 23 '18 at 12:17



















-1














Test adding:



use Appbranchname;


at top of your controller.






share|improve this answer
























  • I already added.

    – user3526766
    Nov 23 '18 at 11:47











  • I delete one line from controller. NOw this is: $branchname = branchname::where('course_id', $request->id)->get(); //$html = view('auth.register')->with(compact('branchname'))->render(); return response()->json(['success' => true, 'html' => $branchname]);

    – user3526766
    Nov 23 '18 at 11:51











  • It is giving object in console. But not showing in select

    – user3526766
    Nov 23 '18 at 11:51












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53445772%2fhow-to-return-data-from-ajax-to-select-tag%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Use



$html = view('auth.register')->with(compact('branchname'))->render();


This will solve your problem.



Edit :



Problem is with your $("#branch_name").html(data.html);



it should be $("#branch_name").html(data);






share|improve this answer


























  • Sorry, But again same error.

    – user3526766
    Nov 23 '18 at 11:58











  • GET localhost/millennium_alumni_laravel/findbranch?id=7 500 (Internal Server Error)

    – user3526766
    Nov 23 '18 at 11:59











  • If I run localhost/millennium_alumni_laravel/findbranch?id=7 direct then error: (2/2) ErrorException Undefined variable: collegename (View: F:xampphtdocsmillennium_alumni_laravelresourcesviewsauthregister.blade.php)

    – user3526766
    Nov 23 '18 at 12:00











  • So, it means there is a variable you are using inside view named collegename which is not passed to it.

    – Omar Abdullah
    Nov 23 '18 at 12:01











  • Hold on i don't see any collegename in code you posted in question. Do php artisan view:clear to clean you cached view

    – Omar Abdullah
    Nov 23 '18 at 12:03
















1














Use



$html = view('auth.register')->with(compact('branchname'))->render();


This will solve your problem.



Edit :



Problem is with your $("#branch_name").html(data.html);



it should be $("#branch_name").html(data);






share|improve this answer


























  • Sorry, But again same error.

    – user3526766
    Nov 23 '18 at 11:58











  • GET localhost/millennium_alumni_laravel/findbranch?id=7 500 (Internal Server Error)

    – user3526766
    Nov 23 '18 at 11:59











  • If I run localhost/millennium_alumni_laravel/findbranch?id=7 direct then error: (2/2) ErrorException Undefined variable: collegename (View: F:xampphtdocsmillennium_alumni_laravelresourcesviewsauthregister.blade.php)

    – user3526766
    Nov 23 '18 at 12:00











  • So, it means there is a variable you are using inside view named collegename which is not passed to it.

    – Omar Abdullah
    Nov 23 '18 at 12:01











  • Hold on i don't see any collegename in code you posted in question. Do php artisan view:clear to clean you cached view

    – Omar Abdullah
    Nov 23 '18 at 12:03














1












1








1







Use



$html = view('auth.register')->with(compact('branchname'))->render();


This will solve your problem.



Edit :



Problem is with your $("#branch_name").html(data.html);



it should be $("#branch_name").html(data);






share|improve this answer















Use



$html = view('auth.register')->with(compact('branchname'))->render();


This will solve your problem.



Edit :



Problem is with your $("#branch_name").html(data.html);



it should be $("#branch_name").html(data);







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 23 '18 at 13:02

























answered Nov 23 '18 at 11:55









Omar AbdullahOmar Abdullah

1947




1947













  • Sorry, But again same error.

    – user3526766
    Nov 23 '18 at 11:58











  • GET localhost/millennium_alumni_laravel/findbranch?id=7 500 (Internal Server Error)

    – user3526766
    Nov 23 '18 at 11:59











  • If I run localhost/millennium_alumni_laravel/findbranch?id=7 direct then error: (2/2) ErrorException Undefined variable: collegename (View: F:xampphtdocsmillennium_alumni_laravelresourcesviewsauthregister.blade.php)

    – user3526766
    Nov 23 '18 at 12:00











  • So, it means there is a variable you are using inside view named collegename which is not passed to it.

    – Omar Abdullah
    Nov 23 '18 at 12:01











  • Hold on i don't see any collegename in code you posted in question. Do php artisan view:clear to clean you cached view

    – Omar Abdullah
    Nov 23 '18 at 12:03



















  • Sorry, But again same error.

    – user3526766
    Nov 23 '18 at 11:58











  • GET localhost/millennium_alumni_laravel/findbranch?id=7 500 (Internal Server Error)

    – user3526766
    Nov 23 '18 at 11:59











  • If I run localhost/millennium_alumni_laravel/findbranch?id=7 direct then error: (2/2) ErrorException Undefined variable: collegename (View: F:xampphtdocsmillennium_alumni_laravelresourcesviewsauthregister.blade.php)

    – user3526766
    Nov 23 '18 at 12:00











  • So, it means there is a variable you are using inside view named collegename which is not passed to it.

    – Omar Abdullah
    Nov 23 '18 at 12:01











  • Hold on i don't see any collegename in code you posted in question. Do php artisan view:clear to clean you cached view

    – Omar Abdullah
    Nov 23 '18 at 12:03

















Sorry, But again same error.

– user3526766
Nov 23 '18 at 11:58





Sorry, But again same error.

– user3526766
Nov 23 '18 at 11:58













GET localhost/millennium_alumni_laravel/findbranch?id=7 500 (Internal Server Error)

– user3526766
Nov 23 '18 at 11:59





GET localhost/millennium_alumni_laravel/findbranch?id=7 500 (Internal Server Error)

– user3526766
Nov 23 '18 at 11:59













If I run localhost/millennium_alumni_laravel/findbranch?id=7 direct then error: (2/2) ErrorException Undefined variable: collegename (View: F:xampphtdocsmillennium_alumni_laravelresourcesviewsauthregister.blade.php)

– user3526766
Nov 23 '18 at 12:00





If I run localhost/millennium_alumni_laravel/findbranch?id=7 direct then error: (2/2) ErrorException Undefined variable: collegename (View: F:xampphtdocsmillennium_alumni_laravelresourcesviewsauthregister.blade.php)

– user3526766
Nov 23 '18 at 12:00













So, it means there is a variable you are using inside view named collegename which is not passed to it.

– Omar Abdullah
Nov 23 '18 at 12:01





So, it means there is a variable you are using inside view named collegename which is not passed to it.

– Omar Abdullah
Nov 23 '18 at 12:01













Hold on i don't see any collegename in code you posted in question. Do php artisan view:clear to clean you cached view

– Omar Abdullah
Nov 23 '18 at 12:03





Hold on i don't see any collegename in code you posted in question. Do php artisan view:clear to clean you cached view

– Omar Abdullah
Nov 23 '18 at 12:03













0














You can try this code:



$.ajax({



        url: base_url + '/findbranch',
type: "GET",
data: {'id': id},
dataType: 'json',
success: function(data) {

$("#branch_name").html(data.html);
},





share|improve this answer
























  • Sorry. It is also not working

    – user3526766
    Nov 23 '18 at 12:17
















0














You can try this code:



$.ajax({



        url: base_url + '/findbranch',
type: "GET",
data: {'id': id},
dataType: 'json',
success: function(data) {

$("#branch_name").html(data.html);
},





share|improve this answer
























  • Sorry. It is also not working

    – user3526766
    Nov 23 '18 at 12:17














0












0








0







You can try this code:



$.ajax({



        url: base_url + '/findbranch',
type: "GET",
data: {'id': id},
dataType: 'json',
success: function(data) {

$("#branch_name").html(data.html);
},





share|improve this answer













You can try this code:



$.ajax({



        url: base_url + '/findbranch',
type: "GET",
data: {'id': id},
dataType: 'json',
success: function(data) {

$("#branch_name").html(data.html);
},






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '18 at 11:59









PHP GeekPHP Geek

1,4301719




1,4301719













  • Sorry. It is also not working

    – user3526766
    Nov 23 '18 at 12:17



















  • Sorry. It is also not working

    – user3526766
    Nov 23 '18 at 12:17

















Sorry. It is also not working

– user3526766
Nov 23 '18 at 12:17





Sorry. It is also not working

– user3526766
Nov 23 '18 at 12:17











-1














Test adding:



use Appbranchname;


at top of your controller.






share|improve this answer
























  • I already added.

    – user3526766
    Nov 23 '18 at 11:47











  • I delete one line from controller. NOw this is: $branchname = branchname::where('course_id', $request->id)->get(); //$html = view('auth.register')->with(compact('branchname'))->render(); return response()->json(['success' => true, 'html' => $branchname]);

    – user3526766
    Nov 23 '18 at 11:51











  • It is giving object in console. But not showing in select

    – user3526766
    Nov 23 '18 at 11:51
















-1














Test adding:



use Appbranchname;


at top of your controller.






share|improve this answer
























  • I already added.

    – user3526766
    Nov 23 '18 at 11:47











  • I delete one line from controller. NOw this is: $branchname = branchname::where('course_id', $request->id)->get(); //$html = view('auth.register')->with(compact('branchname'))->render(); return response()->json(['success' => true, 'html' => $branchname]);

    – user3526766
    Nov 23 '18 at 11:51











  • It is giving object in console. But not showing in select

    – user3526766
    Nov 23 '18 at 11:51














-1












-1








-1







Test adding:



use Appbranchname;


at top of your controller.






share|improve this answer













Test adding:



use Appbranchname;


at top of your controller.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '18 at 11:43









Riccardo MelRiccardo Mel

317




317













  • I already added.

    – user3526766
    Nov 23 '18 at 11:47











  • I delete one line from controller. NOw this is: $branchname = branchname::where('course_id', $request->id)->get(); //$html = view('auth.register')->with(compact('branchname'))->render(); return response()->json(['success' => true, 'html' => $branchname]);

    – user3526766
    Nov 23 '18 at 11:51











  • It is giving object in console. But not showing in select

    – user3526766
    Nov 23 '18 at 11:51



















  • I already added.

    – user3526766
    Nov 23 '18 at 11:47











  • I delete one line from controller. NOw this is: $branchname = branchname::where('course_id', $request->id)->get(); //$html = view('auth.register')->with(compact('branchname'))->render(); return response()->json(['success' => true, 'html' => $branchname]);

    – user3526766
    Nov 23 '18 at 11:51











  • It is giving object in console. But not showing in select

    – user3526766
    Nov 23 '18 at 11:51

















I already added.

– user3526766
Nov 23 '18 at 11:47





I already added.

– user3526766
Nov 23 '18 at 11:47













I delete one line from controller. NOw this is: $branchname = branchname::where('course_id', $request->id)->get(); //$html = view('auth.register')->with(compact('branchname'))->render(); return response()->json(['success' => true, 'html' => $branchname]);

– user3526766
Nov 23 '18 at 11:51





I delete one line from controller. NOw this is: $branchname = branchname::where('course_id', $request->id)->get(); //$html = view('auth.register')->with(compact('branchname'))->render(); return response()->json(['success' => true, 'html' => $branchname]);

– user3526766
Nov 23 '18 at 11:51













It is giving object in console. But not showing in select

– user3526766
Nov 23 '18 at 11:51





It is giving object in console. But not showing in select

– user3526766
Nov 23 '18 at 11:51


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53445772%2fhow-to-return-data-from-ajax-to-select-tag%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Paul Cézanne

UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

Angular material date-picker (MatDatepicker) auto completes the date on focus out