Reputation: 673
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!
Upvotes: 2
Views: 12625
Reputation: 778
I you are working in the same domain, use relative path.
If not, you need enable 'crossDomain' option.
Upvotes: 1
Reputation: 13997
Just remove the whole domain part, only use the relative path:
$.ajax({
url: '/test/suma.php',
type: 'post',
// other stuff
});
Upvotes: 2