}
}
$id = h("val[$unique_idf][" . bracket_escape($key) . "]");
- $value = $_POST["val"][$unique_idf][bracket_escape($key)];
+ $value = ($error ? $_POST["val"][$unique_idf][bracket_escape($key)] : null);
$h_value = h(isset($value) ? $value : $row[$key]);
$long = strpos($val, "<i>...</i>");
$editable = is_utf8($val) && !$long && $rows[$n][$key] == $row[$key] && !$functions[$key];
if (!information_schema(DB)) {
?>
<fieldset><legend><?php echo lang('Edit'); ?></legend><div>
-<input type="submit" value="<?php echo lang('Save'); ?>" title="<?php echo lang('Double click on a value to modify it.'); ?>">
+<input type="submit" value="<?php echo lang('Save'); ?>" title="<?php echo lang('Double click on a value to modify it.'); ?>" onclick='return !ajaxForm(this.form);'>
<input type="submit" name="edit" value="<?php echo lang('Edit'); ?>">
<input type="submit" name="clone" value="<?php echo lang('Clone'); ?>">
<input type="submit" name="delete" value="<?php echo lang('Delete'); ?>" onclick="return confirm('<?php echo lang('Are you sure?'); ?> (' + (this.form['all'].checked ? <?php echo $found_rows; ?> : formChecked(this, /check/)) + ')');">
/** Create AJAX request
* @param string
+* @param string
* @return XMLHttpRequest or false in case of an error
*/
-function ajax(url) {
+function ajax(url, data) {
var xmlhttp = (window.XMLHttpRequest ? new XMLHttpRequest() : (window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : false));
if (xmlhttp) {
var currentState = ++ajaxState;
clearTimeout(ajaxTimeout);
ajaxTimeout = setTimeout(function () {
setHtml('main', '<img src="../adminer/static/loader.gif" alt="">');
- }, 1000); // defer displaying loader
- xmlhttp.open('GET', url);
+ }, 500); // defer displaying loader
+ var method = (data === undefined ? 'GET' : 'POST');
+ xmlhttp.open(method, url);
+ if (method == 'POST') {
+ xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+ }
xmlhttp.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState == 4 && currentState == ajaxState) {
setHtml('main', xmlhttp.responseText);
if (window.jush) {
jush.highlight_tag('code');
+ jush.highlight_tag('pre', 0);
}
}
};
- xmlhttp.send('');
+ xmlhttp.send(data);
}
return xmlhttp;
}
var params = [ ];
for (var i=0; i < form.elements.length; i++) {
var el = form.elements[i];
- if (el.name && (!/checkbox|radio/i.test(el.type) || el.checked)) {
- params.push(el.name + '=' + encodeURIComponent(/select/i.test(el.tagName) ? selectValue(el) : el.value));
+ if (el.name && (!/checkbox|radio|submit|file/i.test(el.type) || el.checked)) {
+ params.push(encodeURIComponent(el.name) + '=' + encodeURIComponent(/select/i.test(el.tagName) ? selectValue(el) : el.value));
}
}
- return ajax((form.action || location.pathname) + '?' + params.join('&'));
+ if (form.method == 'post') {
+ return ajax(form.action || location.href, params.join('&'));
+ } else {
+ return ajax((form.action || location.pathname) + '?' + params.join('&'));
+ }
}