Le 2011-05-29 01:38, Thilanka Kaushalya a écrit :
Hi Marc,
(...)
So in server_privileges.php starting at line 2142, instead of using echo to generate the form, it would be gathered in a variable using a logic similar to the one in server_privileges.php starting at line 1357. Then it's either echoed if not coming from an ajax request, or sent via PMA_ajaxResponse().
I went through the process which you have mentioned above. I have replaced echo with collecting variable called $user_form and then handled the ajax_enabeled action as follows.
if($GLOBALS['is_ajax_request'] == true){ $extra_data['user_form'] = $user_form; $message = PMA_Message::success(__('New user has been added.')); PMA_ajaxResponse($message, $message->isSuccess(), $extra_data); }
And in my server_privileges.js file I have called the post method as follows. $testing_parameters = "db=super_store&server=1&token=c6ad5e8e3a8042287e401dc5e739280a&checkprivs=super_store&viewing_mode=db&ajax_request=true"; $.post( $form.attr('action'), $testing_parameters, function(mydata){ $("#usersForm").append(mydata); });
I have used hard coded parameters in $testing_parameters variable and the append the datafor $("#uerForm") for test the feature.
But the appended my data does not returns an json object. it just return a string containing the results. I have share screen shots of the alert and the UI which shows the returned $mydata string with this doc [1]. Can you help me on why this happens.
Thilanka, I don't understand why you are talking about a JSON object. JSON is a text-based notation and in your first screenshot, the text shown is in JSON. It contains a variable "message" with a large chunk of generated HTML. This is fine.
For an example on how this is handled, look in libraries/sql.js in the section $("#sqlqueryform.ajax") to see what is done with data.message.
Please use a similar logic for code consistency with the other parts already ajaxified.
If I'm not going to use the PMA_ajaxResponse() method I can just take the whole post data and extract the new #usersForm out of that and repalace the old one.
Please help me on this issue. Thank you.
[1] - https://docs.google.com/document/d/1DLcwm4VJv-IrLBiwlRwFPs4oaSuC_bPOsxrJ99xW...