Hallo Leute ich mal wieder was fragen.
Ich habe nun das Script mir gebaut:
Damit ich nicht die Hälfte von dem Code doppelt habe müsste ich irgendwie an die Daten aus der Ajax abfrage bekommen.
Vereinfacht gesagt brache ich so was:
Ich habe nur keine ahnung wie das gehen soll.
Kann mir bitte jemand einen Tipp geben.
Gruß
René
Ich habe nun das Script mir gebaut:
Code:
function TD() { $('td').each(function(event) { if ($(this).closest("td").attr('Content_Editable') === 'true') { $(this).mouseover(function() { $(this).css("cursor", "pointer"); }) let td_old = ''; let index = ''; let data_alt = ''; let table_th = ''; let text_old = ''; let table_id = ''; $(this).dblclick(function() { if ($(this).children("input").length > 0) { return false; } td_old = $(this); index = td_old.parent().children().index(this); text_alt = td_old.closest("td").text(); table_th = td_old.parents('tbody').prev().find('tr').children(':eq(' + index + ')').attr('id'); text_old = td_old.text(); table_id = td_old.closest("tr").find("td:eq(0)").text(); td_old.html(""); if ($(this).closest("td").attr('Input') === 'true') { input_new = $("<input type='text' />"); input_new .width(td_old.width()) .height(td_old.height()) .css({ border: "1px solid #000000", fontSize: "17px" }) .val(text_old) .appendTo(td_old) .trigger("focus") .trigger("select"); } function Ajax_Data(data) { alert(data); return data; } console.log(data); if ($(this).closest("td").attr('Select') === 'true') { getData(); console.log(options); input_new = $('<select name="13">' + options + '</select>'); input_new .width(td_old.width()) .height(td_old.height()) .css({ border: "1px solid #000000", fontSize: "17px" }) .appendTo(td_old) } // on Leave input_new.blur(function() { if (text_alt !== $(this).val()) { Write($(this).val()); } else { td_old.html(text_old); } }); // press ENTER-key input_new.keyup(function(event) { if (13 === event.which) { if (text_alt !== $(this).val()) { Write($(this).val()); } else { td_old.html(text_old); } } // press ESC-key else if (27 === event.which) { td_old.html(text_old); } }); function Write(text_new) { $.ajax({ type: "POST", url: "index.php?usw...", dataType: 'json', data: { "TOKEN": $("input[name=CSRF_TOKEN]").val(), "TABLE_ID": table_id, "TEXT_OLD": text_old, "TEXT_NEW": text_new, "TABLE_HEAD": table_th }, success: function(Response) { if (Response === "1") { td_old.html(text_new); } else { Info_Box(); } } }); } function getData() { $.ajax({ dataType: 'json', data: { "TOKEN": $("input[name=CSRF_TOKEN]").val() }, type: "POST", url: 'index.php?usw...', success: Ajax_Data }) } }); } }); }
Vereinfacht gesagt brache ich so was:
Code:
function Oben() { code ..... function innen(data) { alert(data); } console.log(data); code ..... }
Kann mir bitte jemand einen Tipp geben.
Gruß
René
Kommentar