Hello. There was such a situation. It is necessary to insert data into the database with a javascript file. In this case, the JS file is generated with a double click (I make an extension for Firefox - word translation). There is also a website in PHP, which displays data from this database. How can I transfer data to a MySQL site or DB from a javascript file?

JS-file (part):

var coords = [event.pageX, event.pageY]; var dictDiv = $("<div class='dict' style='display: none;'>"); var engDiv = $('<div class="eng list"></div>'); var rusDiv = $('<div class="rus list"></div>'); engDiv.html(dictResult).appendTo(dictDiv); rusDiv.html(rusWords).appendTo(dictDiv); dictDiv.offset({top:coords[1], left:coords[0]}); dictDiv.appendTo('body'); dictDiv.on('mousedown', function () { var popupString = $(this).text(); var popupArray = popupString.split(' '); var popupTranslate = ''; $(rusDiv).on('mouseup', 'div', function () { popupTranslate = $(this).text(); popupTranslate = popupTranslate.split(' '); var outputArray = popupArray.splice(0, 2); //этот масив нужно отправить в БД var result = outputArray.concat(popupTranslate); }); }); 

array looks like this (example): ["code", "kəʊd", "код", "сущ"]

  • uh, ajax ? Look in the open spaces. A lot of information about this - Vasily Barbashev

0