[IGNORE] url to send a POST request with AJAX



I’m testing AJAX with a simple XMLHTTP request but no luck


// data variable supplied elsewhere

url = ‘scribbles.php’;

var r = new XMLHttpRequest();

r.open(‘POST’, url, true);

on scribbles.php
all I’m doing is var_dump($_POST);

but no luck, I get an empty array

both the script and the php page are on my workspace.

Is it a url problem?
tried various ways e.g ide.c9.io/myUserName/myWorkspace/scribbles.php



When making requests with Ajax I simply entered the path of the php file. Have you tried localhost/filename.php?


Within the IDE, navigate to the folder that has “scribbles.php”, right click on “scribbles.php” and choose “open terminal here”. Then, within the terminal, type “pwd” and hit enter. That is the command for “Print Working Directory”. That will give you the exact path of scribbles.php that you can then use in your script.


Oh my word I’m awfully sorry
it turns out the problem was the way I sent the data.

For everyone’s benefit the best answer on how to POST and retrieve data in JSON format
to a php server is at stack overflow here:

AJAX: JSON to PHP and back again, no jQuery


thanks very much everyone for replying!

the url was fine as it was scribbles.php
the problem was the data format being sent over AJAX!
See above