I’m currently working on how to send a JavaScript to PHP server side.
I tryed playing with jquery ajax, but it requires a submit (as far as i understand?) before it can send data. My question is how can i send som data from Javascript to PHP without submitting?
I fiddled with folowing code, but can’t receive the data at editproduct.php
$.ajax({
url: 'includes/editproduct/editproduct.php',
type: 'GET',
data: {
id1: '1',
id2: '2'
});
//PHP:
print_r($_GET); //Does not show any content
When you use
type: 'GET'the data will be stored in$_GET. If you want to store your data in$_POST, usetype: 'POST'.Also, the apostrophes around your vars’ values are not needed. Try
(and mind the missing curly bracket which suppose to close the data section)