Send POST data using XMLHttpRequest

The code below demonstrates on how to do this. var http = new XMLHttpRequest(); var url=”get_data.php”; var params=”orem=ipsum&name=binny”; http.open(‘POST’, url, true); //Send the proper header information along with the request http.setRequestHeader(‘Content-type’, ‘application/x-www-form-urlencoded’); http.onreadystatechange = function() {//Call a function when the state changes. if(http.readyState == 4 && http.status == 200) { alert(http.responseText); } } http.send(params); In … Read more

Receive JSON POST with PHP

Try; $data = json_decode(file_get_contents(‘php://input’), true); print_r($data); echo $data[“operacion”]; From your json and your code, it looks like you have spelled the word operation correctly on your end, but it isn’t in the json. EDIT Maybe also worth trying to echo the json string from php://input. echo file_get_contents(‘php://input’);

jQuery Ajax POST example with PHP

Basic usage of .ajax would look something like this: HTML: <form id=”foo”> <label for=”bar”>A bar</label> <input id=”bar” name=”bar” type=”text” value=”” /> <input type=”submit” value=”Send” /> </form> jQuery: // Variable to hold request var request; // Bind to the submit event of our form $(“#foo”).submit(function(event){ // Prevent default posting of form – put here to work … Read more

jQuery Ajax File Upload

File upload is not possible through AJAX. You can upload file, without refreshing page by using IFrame. You can check further details here. UPDATE With XHR2, File upload through AJAX is supported. E.g. through FormData object, but unfortunately it is not supported by all/old browsers. FormData support starts from following desktop browsers versions. IE 10+ … Read more

How do you use variables within $_POST? [closed]

$_POST is an associative array that is set by forms using the “method=post” attribute. You can access it like the following: Lets say you have the form: <form action=”” method=”post”> Name: <input type=”text” name=”first_name” /> <input type=”submit” value=”Submit” /> </form> You would access the “first_name” input box using the following variable: $_POST[‘first_name’] If “row” is … Read more

How do I post multiple parameters to a URL

If I’ve understood your requirements you need to pass method as a string, then JSON encode the params object. If so, this should work for you: $.post(‘https://liceoeuroamericano.territorio.la/webservices/persona.php’, { method: ‘activateUser’, params: JSON.stringify({ auth_key: “123456”, user: “[email]”, active: “[0/1]” }) }, function(data){ console.log(‘request completed successfully’); })