logo
down
shadow

Using Symfony2, how to get ajax post data from the request?


Using Symfony2, how to get ajax post data from the request?

By : Colby Garrett
Date : November 22 2020, 01:01 AM
it should still fix some issue Finally, the logger of symfony doesn't show me anything on $request->request->all() , but in preview tab in console I could see some var_dump on $request->request->all() and it wasn't empty (I want to swear myself), it contains the 2 first data of request payload (content-disposition form-data), but not the last one (Content-Type: image/jpeg).
I had to change the 2nd data to become
code :
------WebKitFormBoundaryvU5EBWuRkyGkSRBS
Content-Disposition: form-data; name="media_answer[idResp]"

420
$r = $request->request->all(); // or using $request->getContent() it's also possible in a different way
$rt = $r['media_answer']['_token']; // e6583ea5230f1f80a218825ed399115925556f0c
$ri = $r['media_answer']['id-resp']; // 420
$request->files->get('media_answer[answer]', array(), true)
$request->files->get('media_answer[answer]', array(), true)->getClientOriginalName()


Share : facebook icon twitter icon
How to get Ajax post request by symfony2 Controller

How to get Ajax post request by symfony2 Controller


By : Denis Gaidak
Date : March 29 2020, 07:55 AM
I hope this helps you . First, you don't need to access the container in your controller as it already implements ContainerAware
So basically your code should look like this in your Controller.php
code :
public function ajaxAction(Request $request)
{
    $data = $request->request->get('request');
}
Access symfony2 controller from ajax post request

Access symfony2 controller from ajax post request


By : K.Horst
Date : March 29 2020, 07:55 AM
hope this fix your issue You're trying to use a twig function in a file that's not compiled with twig.
You could use the FOSJsRoutingBundle. or pass the value of {{ path('_ajaxUpdateInfo') }} through to your js script from the twig template.
Why is this ajax post request executing a GET request with the data right before the post request is executed in Nodejs

Why is this ajax post request executing a GET request with the data right before the post request is executed in Nodejs


By : helgeklapper
Date : March 29 2020, 07:55 AM
seems to work fine It looks like you are submitting the form and the ajax request. Try adding the following to prevent the default submit action (GET).
code :
.submit(function(e) {
  e.preventDefault();
  //ajax code
}
symfony2's FOSRestController can't validate an ajax post request

symfony2's FOSRestController can't validate an ajax post request


By : MorningCoffee
Date : March 29 2020, 07:55 AM
may help you . This is because you are using handleRequest with empty submitted data I guess. In such scenario you such call:
code :
// remove form->handleRequest call
// $form->handleRequest($this->getRequest());
$form->submit($request->request->all());
`Gallery` => []
ajax post request handle data in symfony2 controller

ajax post request handle data in symfony2 controller


By : Mahesh Babu
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , i really don't understand how to handle with post data from ajax request. This is my javascript: , Do you use the request object in your controller?
Related Posts Related Posts :
  • RangeError: Maximum call stack size exceeded with array.slice
  • node rest client get with local variable
  • If condition not executes while mouse move fastly
  • Count the number of displayed elements in a HTML list
  • Locate JavaScript source code in Emacs
  • Clean, Modular Code vs MV* Frameworks
  • infinite scroll without loading image
  • Backbone: reverse collection order with comparator
  • What do printers ignore?
  • jQuery UI .tabs() Contentless tab?
  • Execute Javascript alert() after page (visually) loaded
  • JavaScript - duplicating array doesn't work
  • Excessive clickable area below image
  • JavaScript Regex: Replace |b| with <b>
  • Unexpected value change in 2D array in JavaScript
  • Function doesnt see parameter as a array of objects
  • jQuery fetch keypress event on chrome and IE
  • How to enable jquery validate localization?
  • Cassandra map collection returned by node.js Helenus looks odd
  • angular ng-repeat with multiple filter options
  • Selecting Children without ID or Class names
  • How to uncheck a group of checkboxes when another checkbox is checked
  • Is hiding content by Javascript or jQuery Worth trying
  • Load XUL resource using javascript
  • XML to HTML text area from server file system
  • set focus() on textbox on form onload
  • es lint '' is assigned a value but never used' eventhough i have used it
  • Can "name" attribute be used for custom VueJS components
  • Get innerHTML of content when it is clicked
  • HTTPS causes CSS animations to not load? Very confused
  • How to hide other div apart from touched div to the band
  • Is global variable assignment atomic on NodeJS?
  • Datepicker onchangemonthyear beforeshowday
  • trying to render html files using jade but it still adresses it as a jade
  • Google Analytics - Understanding and Dissecting the Snippet: What is | | [ ];
  • Replacing "[aA09.b]." to "[aA09.b]\n" in in JavaScript
  • Why wrap a function definition in an immediate function?
  • Enable / disable jQuery script on switching to different tab in a HTML page
  • how can find return variable value outside anonymous function in node js mysql query function
  • Converting 1 to 0001 in javascript array
  • svg viewbox should not resize the text fontSize?
  • store newline character with string in a variable
  • MP4 videos in Flowplayer does not play in Windows 7 Chrome
  • jquery focusin event not firing
  • How to debug Vue application with google chrome
  • html 5 web app cache download complete javascript alert?
  • Ember.js setupController fired only once
  • How to validate a currency input
  • How to convert my Array of data to key & value pair
  • Statistics circles in CSS
  • So I wanted to make a trig solver in javascript?
  • Showing HighCharts series name on x-axis and in legend
  • In Rails, how can we pass parameters in script?
  • Build Fails: `npm rebuild node-sass --force`
  • Angular Datepicker change dateformat
  • Trying to extract data from between two sets of characters
  • Configuring Jest in WebStorm
  • Uncaught Error: Syntax error, unrecognized expression: tr.ec_portfolio_title,
  • JQuery fading in fading out continuously
  • Unexpected end of input (Line 1) and Undefined Function?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org