I have a php that sends POST request to server, it works fine:
<?php
$params = array ('id' => '3','title' => 'test', 'description' => 'testdescription');
$query = http_build_query ($params);
$contextData = array (
'method' => 'POST',
'header' => "Connection: close
".
"Content-Length: ".strlen($query)."
",
'content'=> $query );
$context = stream_context_create (array ( 'http' => $contextData ));
$result = file_get_contents (
'http://95.85.57.158/api/v3/projects/3/issues?private_token=XXXXXX', // page url
false,
$context);
// Server response is now stored in $result variable so you can process it
var_dump($result);
?>
Now I want to rewrite it to JS (jquery) and so I get:
$(".submit").click(function() {
var dataString = {id:"3",title:"test",description:'test'};
//alert (dataString);return false;
$.ajax({
type: "POST",
url: "http://95.85.57.158/api/v3/projects/3/issues?private_token=XXXX",
data: dataString,
dataType: 'json',
success: function() {
alert('done');
}});
return false;
});
});
But i get 404 error on button click( Can anybody tell me what am I doing wrong?
404 means that the Url
http://95.85.57.158/api/v3/projects/3/issues
is not existing but i think you know that.
In you jQuery Post, put Token in the dataString.
And test this Url
http://95.85.57.158/api/v3/projects/3/issues
In your browser for see if it is existing yet.