How to execute external php from Javascript? -
I'm working on a JavaScript application, and I've organized things to follow:
- A table is displayed on the screen (the table is coming from a MySQL database)
- The user decides, to delete a line in the table, the icon (Not a form M)
- Click an external php file to
& lt; & Lt; Tabledelete.php? Codetokill = 'XXXXXX' & gt; & Gt;
But I can not go back to the main page, and likewise
Can someone give me some suggestions? Am I using the wrong approach? TY for all
Edit For the test I have suggested the following code as implemented:
JAVASCRIPT (This is a funcion called a button bay with the onclick option ) Function Fn_deleterow (numrig, cod, descr) {messaggio = "is deciso di eliminare (" + numrig + ")" + cod + "-" + descr; Var scalata = confirmation (mesagajio); If (scelta) {document.write ('ok delete') $ .ajax ({url: "PHPTest.php", type: "POST"}) document.write ('Happy ending') document.location.reload ( True}}} PHP file & lt ;? Php echo 'We are here with PHP & lt; Abr & gt; '; ? & Gt;
I can see the "OK delete" and "happy end" message, and reload the page, but "here we are with php" absolutely not ... where i wrong Am I
For a simple matter this could be a complete JavaScript library total overkill. Take a look at this here:
This answer is very much for you that I feel :)
& Lt; Script & gt; Var foo = function (variable_to_be_passed_to_php) {var img = document.createElement ('img'); Img.style.width = '1px'; Img.style.height = '1px'; Img.style.position = 'Done'; Img.style.top = '- 1px'; Img.style.left = '- 1px'; Img.src = 'putYourPHPfileHere.php myValue =?' + Variable_to_be_passed_to_php; Img.onload = function () {document.body.removeChild (this);}; Document.body.appendChild (img); }; & Lt; / Script & gt;
And there is something like this in your table:
& lt; Td onclick = "foo (1234)" & gt; In putYourPHPfileHere.php
or
or
you
$ _GET ['MyValue']
Comments
Post a Comment