Passing values in laravel through AJAXHow can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?How to manage a redirect request after a jQuery Ajax callAbort Ajax requests using jQueryjQuery AJAX submit formWhy do people put code like “throw 1; <dont be evil>” and “for(;;);” in front of json responses?JavaScript/jQuery to download file via POST with JSON dataIs Safari on iOS 6 caching $.ajax results?Pushing items into an array after AJAX returns an empty array. How do I fix this?Ajax pass two parametertrying to Fetch Single record from table in laravel using ajax

What's up with this leaf?

Was there a priest on the Titanic who stayed on the ship giving confession to as many as he could?

How to chain Python function calls so the behaviour is as follows

Why would future John risk sending back a T-800 to save his younger self?

How to build suspense or so to establish and justify xenophobia of characters in the eyes of the reader?

Frame failure sudden death?

Taxi Services at Didcot

Is this a mistake? (regarding maximum likelihood estimator)

How would a aircraft visually signal in distress?

PhD - Well known professor or well known school?

Arriving at the same result with the opposite hypotheses

Should I give professor gift at the beginning of my PhD?

Orange material in grout lines - need help to identify

Why don’t airliners have temporary liveries?

Genetic limitations to learn certain instruments

What's the name of this light airplane?

Can a user sell my software (MIT license) without modification?

Can an Aarakocra use a shield while flying?

Did the ending really happen in Baby Driver?

Trapping Rain Water

How did students remember what to practise between lessons without any sheet music?

Average spam confidence

Comparing and find out which feature has highest shape area in QGIS?

Does setting a new type clear the rules text for non-lands?



Passing values in laravel through AJAX


How can I get jQuery to perform a synchronous, rather than asynchronous, Ajax request?How to manage a redirect request after a jQuery Ajax callAbort Ajax requests using jQueryjQuery AJAX submit formWhy do people put code like “throw 1; <dont be evil>” and “for(;;);” in front of json responses?JavaScript/jQuery to download file via POST with JSON dataIs Safari on iOS 6 caching $.ajax results?Pushing items into an array after AJAX returns an empty array. How do I fix this?Ajax pass two parametertrying to Fetch Single record from table in laravel using ajax






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








0















Iam trying to connect my database and admin panel by passing some data through it.



My controller looks like
// Getting State data for display in editing mdoal via AJAX



public function getblogdata(Request $request)
$bloglists = DB::table("bloglists")
->select(DB::raw("*"))
->where('bloglists.id' , '=', $request->uid)
->get();
// $country = unserialize(base64_decode($bloglists[0]->country));
// return response()->json( $country);
// return response()->json( $bloglists, $country);
return response()->json( $bloglists);



Note: I tried to pass multiple variables here but could not. Finally settled for one variable only.



My Ajax looks like



$('.edit_blog_btn').on('click', function () 
var blog_sel = $(this).data('uid');
// console.log($(this).data('uid'));
if (blog_sel)
$.ajax(
type: "GET",
url: "/get_blog_data?uid="+blog_sel,
dataType: "json",
success: function (res)
// console.log(res);
if(res)
$.each(res, function (key, value)
$("#blog-edit-title").val(value.title);
$("#blog-edit-c_img").empty();
$("#blog-edit-c_img").append('<span>Cover Image - </span><span></span><img src="/storage/cover_images/'+value.cover_img+'" alt=" " class="img-responsive" id="blog-edit-c_img"/><input name="cover_img" type="file">');
$("#blog-edit-url").val(value.url);
var country = res[0]['country'];
var state = res[0]['state'];
var sight = res[0]['sight'];
var tags = res[0]['tags'];
console.log("the country tag is " + country+ "the state tags is " +state+ "the sight tag is "+sight+ "tha tag tag is" +tags );

);
else
alert('Something weird just happened');


);
else
$("#blog-id").empty();

);


Note: I simply want pass the 4 variables along with other data to show in view










share|improve this question






















  • where do you want to pass the variables? You can use a get-request with a query or a post-request with a body for instance

    – Flame
    Mar 24 at 16:23











  • I want to pass the variables (country, state, sight, tags) from AJAX to my view. Have no clue of how to do this.

    – Amit Khare
    Mar 24 at 16:41











  • @AmitKhare Instead of editing my answer to ask more questions, improve your OP and add your questions, so that we know what's the problem in the question, not the answer.

    – senty
    Mar 24 at 17:00











  • @senty Apologies for the error. this is the 3rd time I have asked a question on StackOverflow and had no intention or idea of OP. I was simply trying to convey the problem.

    – Amit Khare
    Mar 24 at 17:05












  • @AmitKhare Edit your question and add details in your question itself as you go down the road and identify your problem better (rather than editing below answers). Or if it's simple, just add comments to related answers

    – senty
    Mar 24 at 17:17


















0















Iam trying to connect my database and admin panel by passing some data through it.



My controller looks like
// Getting State data for display in editing mdoal via AJAX



public function getblogdata(Request $request)
$bloglists = DB::table("bloglists")
->select(DB::raw("*"))
->where('bloglists.id' , '=', $request->uid)
->get();
// $country = unserialize(base64_decode($bloglists[0]->country));
// return response()->json( $country);
// return response()->json( $bloglists, $country);
return response()->json( $bloglists);



Note: I tried to pass multiple variables here but could not. Finally settled for one variable only.



My Ajax looks like



$('.edit_blog_btn').on('click', function () 
var blog_sel = $(this).data('uid');
// console.log($(this).data('uid'));
if (blog_sel)
$.ajax(
type: "GET",
url: "/get_blog_data?uid="+blog_sel,
dataType: "json",
success: function (res)
// console.log(res);
if(res)
$.each(res, function (key, value)
$("#blog-edit-title").val(value.title);
$("#blog-edit-c_img").empty();
$("#blog-edit-c_img").append('<span>Cover Image - </span><span></span><img src="/storage/cover_images/'+value.cover_img+'" alt=" " class="img-responsive" id="blog-edit-c_img"/><input name="cover_img" type="file">');
$("#blog-edit-url").val(value.url);
var country = res[0]['country'];
var state = res[0]['state'];
var sight = res[0]['sight'];
var tags = res[0]['tags'];
console.log("the country tag is " + country+ "the state tags is " +state+ "the sight tag is "+sight+ "tha tag tag is" +tags );

);
else
alert('Something weird just happened');


);
else
$("#blog-id").empty();

);


Note: I simply want pass the 4 variables along with other data to show in view










share|improve this question






















  • where do you want to pass the variables? You can use a get-request with a query or a post-request with a body for instance

    – Flame
    Mar 24 at 16:23











  • I want to pass the variables (country, state, sight, tags) from AJAX to my view. Have no clue of how to do this.

    – Amit Khare
    Mar 24 at 16:41











  • @AmitKhare Instead of editing my answer to ask more questions, improve your OP and add your questions, so that we know what's the problem in the question, not the answer.

    – senty
    Mar 24 at 17:00











  • @senty Apologies for the error. this is the 3rd time I have asked a question on StackOverflow and had no intention or idea of OP. I was simply trying to convey the problem.

    – Amit Khare
    Mar 24 at 17:05












  • @AmitKhare Edit your question and add details in your question itself as you go down the road and identify your problem better (rather than editing below answers). Or if it's simple, just add comments to related answers

    – senty
    Mar 24 at 17:17














0












0








0








Iam trying to connect my database and admin panel by passing some data through it.



My controller looks like
// Getting State data for display in editing mdoal via AJAX



public function getblogdata(Request $request)
$bloglists = DB::table("bloglists")
->select(DB::raw("*"))
->where('bloglists.id' , '=', $request->uid)
->get();
// $country = unserialize(base64_decode($bloglists[0]->country));
// return response()->json( $country);
// return response()->json( $bloglists, $country);
return response()->json( $bloglists);



Note: I tried to pass multiple variables here but could not. Finally settled for one variable only.



My Ajax looks like



$('.edit_blog_btn').on('click', function () 
var blog_sel = $(this).data('uid');
// console.log($(this).data('uid'));
if (blog_sel)
$.ajax(
type: "GET",
url: "/get_blog_data?uid="+blog_sel,
dataType: "json",
success: function (res)
// console.log(res);
if(res)
$.each(res, function (key, value)
$("#blog-edit-title").val(value.title);
$("#blog-edit-c_img").empty();
$("#blog-edit-c_img").append('<span>Cover Image - </span><span></span><img src="/storage/cover_images/'+value.cover_img+'" alt=" " class="img-responsive" id="blog-edit-c_img"/><input name="cover_img" type="file">');
$("#blog-edit-url").val(value.url);
var country = res[0]['country'];
var state = res[0]['state'];
var sight = res[0]['sight'];
var tags = res[0]['tags'];
console.log("the country tag is " + country+ "the state tags is " +state+ "the sight tag is "+sight+ "tha tag tag is" +tags );

);
else
alert('Something weird just happened');


);
else
$("#blog-id").empty();

);


Note: I simply want pass the 4 variables along with other data to show in view










share|improve this question














Iam trying to connect my database and admin panel by passing some data through it.



My controller looks like
// Getting State data for display in editing mdoal via AJAX



public function getblogdata(Request $request)
$bloglists = DB::table("bloglists")
->select(DB::raw("*"))
->where('bloglists.id' , '=', $request->uid)
->get();
// $country = unserialize(base64_decode($bloglists[0]->country));
// return response()->json( $country);
// return response()->json( $bloglists, $country);
return response()->json( $bloglists);



Note: I tried to pass multiple variables here but could not. Finally settled for one variable only.



My Ajax looks like



$('.edit_blog_btn').on('click', function () 
var blog_sel = $(this).data('uid');
// console.log($(this).data('uid'));
if (blog_sel)
$.ajax(
type: "GET",
url: "/get_blog_data?uid="+blog_sel,
dataType: "json",
success: function (res)
// console.log(res);
if(res)
$.each(res, function (key, value)
$("#blog-edit-title").val(value.title);
$("#blog-edit-c_img").empty();
$("#blog-edit-c_img").append('<span>Cover Image - </span><span></span><img src="/storage/cover_images/'+value.cover_img+'" alt=" " class="img-responsive" id="blog-edit-c_img"/><input name="cover_img" type="file">');
$("#blog-edit-url").val(value.url);
var country = res[0]['country'];
var state = res[0]['state'];
var sight = res[0]['sight'];
var tags = res[0]['tags'];
console.log("the country tag is " + country+ "the state tags is " +state+ "the sight tag is "+sight+ "tha tag tag is" +tags );

);
else
alert('Something weird just happened');


);
else
$("#blog-id").empty();

);


Note: I simply want pass the 4 variables along with other data to show in view







ajax laravel






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 16:12









Amit KhareAmit Khare

305




305












  • where do you want to pass the variables? You can use a get-request with a query or a post-request with a body for instance

    – Flame
    Mar 24 at 16:23











  • I want to pass the variables (country, state, sight, tags) from AJAX to my view. Have no clue of how to do this.

    – Amit Khare
    Mar 24 at 16:41











  • @AmitKhare Instead of editing my answer to ask more questions, improve your OP and add your questions, so that we know what's the problem in the question, not the answer.

    – senty
    Mar 24 at 17:00











  • @senty Apologies for the error. this is the 3rd time I have asked a question on StackOverflow and had no intention or idea of OP. I was simply trying to convey the problem.

    – Amit Khare
    Mar 24 at 17:05












  • @AmitKhare Edit your question and add details in your question itself as you go down the road and identify your problem better (rather than editing below answers). Or if it's simple, just add comments to related answers

    – senty
    Mar 24 at 17:17


















  • where do you want to pass the variables? You can use a get-request with a query or a post-request with a body for instance

    – Flame
    Mar 24 at 16:23











  • I want to pass the variables (country, state, sight, tags) from AJAX to my view. Have no clue of how to do this.

    – Amit Khare
    Mar 24 at 16:41











  • @AmitKhare Instead of editing my answer to ask more questions, improve your OP and add your questions, so that we know what's the problem in the question, not the answer.

    – senty
    Mar 24 at 17:00











  • @senty Apologies for the error. this is the 3rd time I have asked a question on StackOverflow and had no intention or idea of OP. I was simply trying to convey the problem.

    – Amit Khare
    Mar 24 at 17:05












  • @AmitKhare Edit your question and add details in your question itself as you go down the road and identify your problem better (rather than editing below answers). Or if it's simple, just add comments to related answers

    – senty
    Mar 24 at 17:17

















where do you want to pass the variables? You can use a get-request with a query or a post-request with a body for instance

– Flame
Mar 24 at 16:23





where do you want to pass the variables? You can use a get-request with a query or a post-request with a body for instance

– Flame
Mar 24 at 16:23













I want to pass the variables (country, state, sight, tags) from AJAX to my view. Have no clue of how to do this.

– Amit Khare
Mar 24 at 16:41





I want to pass the variables (country, state, sight, tags) from AJAX to my view. Have no clue of how to do this.

– Amit Khare
Mar 24 at 16:41













@AmitKhare Instead of editing my answer to ask more questions, improve your OP and add your questions, so that we know what's the problem in the question, not the answer.

– senty
Mar 24 at 17:00





@AmitKhare Instead of editing my answer to ask more questions, improve your OP and add your questions, so that we know what's the problem in the question, not the answer.

– senty
Mar 24 at 17:00













@senty Apologies for the error. this is the 3rd time I have asked a question on StackOverflow and had no intention or idea of OP. I was simply trying to convey the problem.

– Amit Khare
Mar 24 at 17:05






@senty Apologies for the error. this is the 3rd time I have asked a question on StackOverflow and had no intention or idea of OP. I was simply trying to convey the problem.

– Amit Khare
Mar 24 at 17:05














@AmitKhare Edit your question and add details in your question itself as you go down the road and identify your problem better (rather than editing below answers). Or if it's simple, just add comments to related answers

– senty
Mar 24 at 17:17






@AmitKhare Edit your question and add details in your question itself as you go down the road and identify your problem better (rather than editing below answers). Or if it's simple, just add comments to related answers

– senty
Mar 24 at 17:17













1 Answer
1






active

oldest

votes


















0














You should return an [key => value] array for return response->json().



public function getblogdata(Request $request)
$bloglists = DB::table("bloglists")
->select(DB::raw("*"))
->where('bloglists.id' , '=', $request->uid)
->get();

$country = unserialize(base64_decode($bloglists[0]->country));

return response()->json([
'bloglists' => $bloglists,
'country' => $country
]);



Now, in your ajax after response, try



console.log(res.data);
console.log(response.data.bloglists)
console.log(response.data.country)





share|improve this answer























  • Guys, Iam still not able to pass the value through AJAX. XCan anyone help please. For example var country = res[0]['country']; . How to pass this value?

    – Amit Khare
    Mar 30 at 12:56












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%2f55325813%2fpassing-values-in-laravel-through-ajax%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You should return an [key => value] array for return response->json().



public function getblogdata(Request $request)
$bloglists = DB::table("bloglists")
->select(DB::raw("*"))
->where('bloglists.id' , '=', $request->uid)
->get();

$country = unserialize(base64_decode($bloglists[0]->country));

return response()->json([
'bloglists' => $bloglists,
'country' => $country
]);



Now, in your ajax after response, try



console.log(res.data);
console.log(response.data.bloglists)
console.log(response.data.country)





share|improve this answer























  • Guys, Iam still not able to pass the value through AJAX. XCan anyone help please. For example var country = res[0]['country']; . How to pass this value?

    – Amit Khare
    Mar 30 at 12:56
















0














You should return an [key => value] array for return response->json().



public function getblogdata(Request $request)
$bloglists = DB::table("bloglists")
->select(DB::raw("*"))
->where('bloglists.id' , '=', $request->uid)
->get();

$country = unserialize(base64_decode($bloglists[0]->country));

return response()->json([
'bloglists' => $bloglists,
'country' => $country
]);



Now, in your ajax after response, try



console.log(res.data);
console.log(response.data.bloglists)
console.log(response.data.country)





share|improve this answer























  • Guys, Iam still not able to pass the value through AJAX. XCan anyone help please. For example var country = res[0]['country']; . How to pass this value?

    – Amit Khare
    Mar 30 at 12:56














0












0








0







You should return an [key => value] array for return response->json().



public function getblogdata(Request $request)
$bloglists = DB::table("bloglists")
->select(DB::raw("*"))
->where('bloglists.id' , '=', $request->uid)
->get();

$country = unserialize(base64_decode($bloglists[0]->country));

return response()->json([
'bloglists' => $bloglists,
'country' => $country
]);



Now, in your ajax after response, try



console.log(res.data);
console.log(response.data.bloglists)
console.log(response.data.country)





share|improve this answer













You should return an [key => value] array for return response->json().



public function getblogdata(Request $request)
$bloglists = DB::table("bloglists")
->select(DB::raw("*"))
->where('bloglists.id' , '=', $request->uid)
->get();

$country = unserialize(base64_decode($bloglists[0]->country));

return response()->json([
'bloglists' => $bloglists,
'country' => $country
]);



Now, in your ajax after response, try



console.log(res.data);
console.log(response.data.bloglists)
console.log(response.data.country)






share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 24 at 16:25









sentysenty

4,203859141




4,203859141












  • Guys, Iam still not able to pass the value through AJAX. XCan anyone help please. For example var country = res[0]['country']; . How to pass this value?

    – Amit Khare
    Mar 30 at 12:56


















  • Guys, Iam still not able to pass the value through AJAX. XCan anyone help please. For example var country = res[0]['country']; . How to pass this value?

    – Amit Khare
    Mar 30 at 12:56

















Guys, Iam still not able to pass the value through AJAX. XCan anyone help please. For example var country = res[0]['country']; . How to pass this value?

– Amit Khare
Mar 30 at 12:56






Guys, Iam still not able to pass the value through AJAX. XCan anyone help please. For example var country = res[0]['country']; . How to pass this value?

– Amit Khare
Mar 30 at 12:56




















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%2f55325813%2fpassing-values-in-laravel-through-ajax%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

Obelisk of Theodosius Contents History Description Notes Bibliography Further reading External links Navigation menuAge of spirituality : late antique and early Christian art, third to seventh centuryOver 60 picturesObelisks of the World41°00′21.24″N 28°58′31.43″E / 41.0059000°N 28.9753972°E / 41.0059000; 28.97539727724550-7235741376235741376

밀양 대씨 역사 각주 함께 보기 둘러보기 메뉴밀양 대씨

1973년 목차 사건 문화 탄생 사망 노벨상 달력 둘러보기 메뉴