I'm new to Symfony2. Now I want to implement my previous practice for ajax call using Symfony2.
I want to make an ajax call to a server side code and get XML response and extract it. Here is what I do.
var data={
type:'1'
};
jQuery.ajax({
url: 'server_script/check.php', //load data
global: false,
type: "POST",
dataType: "xml",
data: data,
async: false,
success: load_data2
});
In flat php file I can catch that and using
$type=$_POST['type'];
In Symfony2 I'm making AJAX call by using
jQuery.ajax({
url: '{{ path('create_label') }}', //load data
global: false,
type: "POST",
dataType: "xml",
data: data,
async: false,
success: load_data2,
error: problem
});
And in Controller that comes from the create_label,I catch it using
$type->request->get('type');
I'm not sure yet though if it's really working. Got it from this link Link
Next in flat PHP I produce a XML response by
header("Content-type: text/xml");
echo "<?xml version=\"1.0\" ?>
";
echo "<Loadinglist>
";
echo "</Loadinglist>";
It gave me a response that I extract in function load_data2(xmlindata)
method.
Now I'm not able to make any valid XML response in Symfony2. I tried few tricks but none of them are working. I want to send a XML response from Controller , catch it and extract in with the load_data2
method. If you have time please provide an wiki type answer that how the xml response work is done.
(N.B. In flat php I could check the XML response in console or firebug, will I be able to view the same in Symfony2)