Im doing an ajax post but I have a problem.
I want to post to an url but I want to accept in the explorer, "localhost" and the "IP address".
If I put like this:
$.ajax({
url: 'http://192.168.9.30/test/suma.php',
type: 'post',
data: {rows:rowValues, columns:columnValues},
dataType: 'json',
success: function(data){
var rows = data.rows,
columns = data.columns;
// Insertar lo calculado
$("td.total").each(function(rowIndex){
$(this).text(rows[rowIndex+1]);
});
$("tr.totalCol td").each(function(columnIndex){
$(this).text(columns[columnIndex+1]);
});
}
});
Only accept me typing the url, its possible to do it with the url and localhost too?
Thank You in advance!
Im doing an ajax post but I have a problem.
I want to post to an url but I want to accept in the explorer, "localhost" and the "IP address".
If I put like this:
$.ajax({
url: 'http://192.168.9.30/test/suma.php',
type: 'post',
data: {rows:rowValues, columns:columnValues},
dataType: 'json',
success: function(data){
var rows = data.rows,
columns = data.columns;
// Insertar lo calculado
$("td.total").each(function(rowIndex){
$(this).text(rows[rowIndex+1]);
});
$("tr.totalCol td").each(function(columnIndex){
$(this).text(columns[columnIndex+1]);
});
}
});
Only accept me typing the url, its possible to do it with the url and localhost too?
Thank You in advance!
Share Improve this question edited Apr 28, 2014 at 9:18 Funereal asked Apr 28, 2014 at 9:09 FunerealFunereal 6732 gold badges12 silver badges34 bronze badges 4- Can you show us some actual code you're working with? As it is right now, the question is a little vague. – Cerbrus Commented Apr 28, 2014 at 9:16
- @Cerbrus Updated. When I type in browser "localhost/test/suma.php" dont work the POST, only with the IP. – Funereal Commented Apr 28, 2014 at 9:19
-
just use the
/test/suma.php
part as url:url: '/test/suma.php'
– devqon Commented Apr 28, 2014 at 9:37 - @user3153169 Is not possible to do it with keeping the ip address and when I put in the browser localhost, accept as crossdomain? – Funereal Commented Apr 28, 2014 at 9:44
2 Answers
Reset to default 2Just remove the whole domain part, only use the relative path:
$.ajax({
url: '/test/suma.php',
type: 'post',
// other stuff
});
I you are working in the same domain, use relative path.
If not, you need enable 'crossDomain' option.