Reputation: 53826
I'm using an ajax request to retrun json from a URL.
This is working locally as below :
$.ajax({
url: "http://localhost:8080/updates.json",
type: 'post',
dataType : "json",
success : function(jsonResponse) {
});
},
error: function (err) {
}
});
The url needs to be updated so that it works no matter the na eof server its deployed on.
Can url be replaced with something like : "http://"+getThisHostName()+":8080/updates.json" ?
Is there a safe way of returning the current hostname path ?
Upvotes: 1
Views: 1741
Reputation: 119847
You could do it like this
//say you are on http://domain.com:8080
//this will request from http://domain.com:8080/updates.json
$.ajax({
url: "/updates.json",
...
});
Upvotes: 2