Reputation: 4190
I have an HTML file with the URL localhost/dir1/dir2/file.html
. In this file I send data through jquery to the server.
$('#element').live("change", function(){
$.ajax({
url: "localhost/dir1/dir3/file.php",
type: "POST",
data: { esp: $(this).val() },
success: function(result){
$("#element2").html(result);
}
})
I get an error due to jquery send the data to localhost/dir1/dir2/localhost/dir1/dir3/file.php
but I need send the data to localhost/dir1/dir3/file.php
.
How can I do this?
Upvotes: 3
Views: 2003
Reputation: 16659
Change your url to:
/dir1/dir3/file.php
This avoids hardcoding the protocol and server into your code.
Upvotes: 5