I want to use Ajax to past POST parameters in one of my controller.
For this, i did this code :
<script type="text/javascript">
document.getElementById('navbar').style.visibility='hidden';
idacc = $("#idAcc").data();
console.log(idacc);
var form = $("#form");
div = form.find("div");
console.log(div);
$("#ajax").click(function(div){
$.ajax({
type: "POST",
url: "/message/add/" + {{ id }},
data: div,
success: function(div){
console.log(div);
console.log($(this));
}
});
console.log("click");
});
</script>
It's a little script that i've made while i was searching in the web.
My html struct is :
<div class="form>
<div>...</div>
<div>...</div>
<div>...</div>
<div>...</div>
.....
</div>
So with my script, the div variable receive all of the div in the div with the "form" class. It's ok when i dump it in the success function, i have what i want. But when I see in the symfony toolbar POST parameters, there's nothing, i tried to do this as well :
data: { 'div': div }
I'm getting an error
Uncaught TypeError: Cannot read property 'defaultView' of undefined