साथ Symfony2 में टेम्पलेट रेंडर मैं इस पथajax
public function indexAction()
{
return $this->render('AcmeDemoBundle:Plugin:index.html.twig');
}
और index.html सूचकांक मार्ग
routing.yml
index:
pattern: /index
defaults: { _controller:AcmeDemoBundle:Default:index }
नियंत्रक के लिए मेरे नियंत्रक में एक कार्रवाई है .twig टेम्पलेट
{% extends'::base.html.twig' %}
{% block stylesheets %}
{% stylesheets filter='cssrewrite' output='css/*.css'
'bundles/acmedemo/css/*' %}
<link href="{{ asset_url }}" type="text/css" rel="stylesheet" />
{% endstylesheets %}
{% endblock stylesheets %}
{% block body %}
<br>
<div class="container">
<div class="wp_attachment_holder">
<div class="imgedit-response" id="imgedit-response-8"></div>
<div class="wp_attachment_image" id="media-head-8">
<p id="thumbnail-head-8"><img class="thumbnail" src="http://localhost/wordpress/wp-content/uploads/2014/06/121-1024x583.jpeg" style="max-width:100%" alt=""></p>
<p><a class="btn btn-sm btn-default" id="edik-wp-extended-edit">Редактировать</a> <span class="spinner"></span></p>
</div>
<div style="display:none" class="image-editor" id="image-editor-8">
</div>
</div>
<div id="output"></div>
<img class="thumbnail" data-attach-id="8" data-src="http://localhost/wordpress/wp-content/uploads/2014/06/121-1024x583.jpeg" style="max-width:100%" alt="">
<script>
$('#edik-wp-extended-edit').click(function() {
window.location= Routing.generate('ajax');
// $('#output').load('/ajax/index');
});
</script>
</div>
{% endblock %}`
जब बटन Редактировать क्लिक किया गया है तो मैं AJAX के साथ एक और टेम्पलेट लोड करना चाहता हूं।
another.html.twig
<div>Hello</div>
routing.yml इस पथ
public function ajaxAction()
{
$template = $this->renderView('AcmeDemoBundle:Plugin:another.html.twig');
return new Response($template);
}
के लिए
ajax:
pattern: /ajax/index
defaults: { _controller :AcmeDemoBundle:Default:ajax }
options:
expose: true
नियंत्रक लेकिन जब मैं बटन पर क्लिक करें मेरी uri /ajax/index
हो जाएगा। मुझे क्या चाहिए यह है कि यह /index
तक रहता है और टेम्पलेट को मेरे इंडेक्स टेम्पलेट
में क्या किया जा रहा है मैं गलत क्या कर रहा हूं?
धन्यवाद।
मेरे लिए यह जवाब सबसे अच्छा है http://stackoverflow.com/a/23209195/2008111 – caramba