ajax - returning two responses in one function call (symfony) -
i return 2 responses in function. possible? think that's not possible. here problem. got function called addschool in controller. function:
public function addschoolaction($id, request $request){ $school = new school(); $form = $this->createform(schooltype::class, $school); $form->handlerequest($request); if ($request->isxmlhttprequest()) { $session = $request->getsession(); $school = ... // getting required school database $session->set('school', $school); return new response($school->name()); // thing that: // return new response($school->name()) // && new response($school->phonenumber()); } return $this->render('appbundle:listofschools.html.twig', array( 'form' => $form->createview(), 'schools' => $response->body, ));
and here ajax function call function:
function ajaxfirstid (ok) { var url = '{{ path('add_school', {'id': 'ok'}) }}'; url = url.replace("ok", ok); $.ajax({ type: 'post', url: url, success: function (response) { $('#schoolname').val(response); } }); }
so works me, replaces field name of school true name, if want name , phonenumber how can this? thanks.
Comments
Post a Comment