Note that there are some explanatory texts on larger screens.

plurals
  1. POajax post request handle data in symfony2 controller
    primarykey
    data
    text
    <p>i really don't understand how to handle with post data from ajax request. This is my javascript:</p> <pre><code>$.ajax({ type: "POST", url: Routing.generate('save'), contentType: 'application/json; charset=UTF-8', data: { title: title, description: description, questions: questions, } }); </code></pre> <p>The only way to get the data inside my controller action is this:</p> <pre><code>$content = $request-&gt;getContent() </code></pre> <p>$content is a url parameter string. Why don't i get the data normally with:</p> <pre><code>$request-&gt;get('title') </code></pre> <p>What is the correct way to handle the post data with jquery ajax methd?</p> <p>Thank you very much.</p> <p><strong>EDIT</strong></p> <p>So, i found out the following issue:</p> <p>In my current project the request looks like this:</p> <p><img src="https://i.stack.imgur.com/O0BAg.png" alt="https://dl.dropboxusercontent.com/u/17861060/false.png"></p> <pre><code>$.ajax({ type: "POST", url: Routing.generate('poll_save'), data: { title: title } }) </code></pre> <p>The data is requested via <strong>Request Payload</strong> but i don't know why.</p> <p>In a clean project the request looks like this:</p> <p><img src="https://i.stack.imgur.com/ShcVI.png" alt="https://dl.dropboxusercontent.com/u/17861060/right.png"></p> <pre><code>$.ajax({ type: "POST", url: '{{path('_demo')}}', data: { title: 'title', description: 'description', questions: 'questions', pollid: 1 } }) </code></pre> <p>Anything in my project is going wrong. Do you have an idea why the data is requested via <strong>Request Payload</strong>?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload