When open-event of modal dialog_window i try to get one row from sql db where id = var from another_element (var is passed successfully here, I checked).
$("#dialog_window").dialog({ open: function() { var id = $("#another_element").data('id'); $.ajax({ type: 'POST', url: 'response.php', data: id, success: function(data) { alert(data['F']); //try to show one of the elements of the array }, error: function(xhr, str){ alert(xhr.responseCode); } }); }, ......... ......... });
response.php:
<?php $name = 'name'; $password = 'password'; header("Content-Type: text/html;charset=utf-8"); mysql_connect("localhost", "$name", "$password") or die(mysql_error()); mysql_select_db("database") or die(mysql_error()); $str = "Select * from table WHERE id='".$_REQUEST['id']."'"; $result = mysql_query($str) or die(mysql_error()); $row=mysql_fetch_assoc($result); //I tried to use mysql_fetch_assoc and //mysql_fetch_row mysql_close(); echo($row); ?>