heroku javascript ajax post not returning anything

I'm trying to do a ajax post to a heroku server app and have the app return a response to the client web page (on a different server).

It works just fine if I test it locally (using localhost) but when I push to heroku, I get no response.

app.js:

var express = require('express');
var app = express();

app.use(express.bodyParser()).post('/', function(req, res){
res.header("Access-Control-Allow-Origin", "*").header("Access-Control-Allow-Headers", "X-Requested-With").header('Access-Control-Allow-Methods: POST, GET, OPTIONS');
res.end("test");
});

    port = process.env.PORT || 3000;
    app.listen(port);

client-side js:

$.post("http://myapp-name-here.heroku.com", {query: "anything", val: "something"},
function(data){
     console.log(data);
});

Edited in:

When I open the client-side html page, when it makes the post request, it gets the status "canceled" after a couple of seconds. Any ideas?

Answers


myapp-name-here.heroku.com is no longer supported, try myapp-name-here.herokuapp.com


Need Your Help

Disable the enter key on a jquery-powered form

php jquery webforms

I have a form using the form jQuery plug in to handel the posting of the data. In the example i am working with the data is psoted to another php file which reades a database and echos back a result

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.