I am trying to access a PHP file which is located in my domain but I want to do that using AJAX with jQuer. I am using a localhost and from there I am trying to call the PHP file here is the code I am using :
<script>
$(function() {
$("#callAjax").click(function() {
var theName = $.trim($("#theName").val());
if(theName.length > 0)
{
$.ajax({
type: "POST",
url: "http://studiofutbol.com.ec/upload_file.php",
data: ({name: theName}),
cache: false,
dataType: "text",
success: onSuccess
});
}
});
$("#resultLog").ajaxError(function(event, request, settings, exception) {
$("#resultLog").html("Error Calling: " + settings.url + "<br />HTPP Code: " + request.status);
});
function onSuccess(data)
{
$("#resultLog").html("Result: " + data);
$('#people_list').append("hola");
$('#people_list').listview('ref resh');
}
});
</script>
But I get this error:
XMLHttpRequest cannot load http://studiofutbol.com.ec/upload_file.php . Origin http://localhost is not allowed by Access-Control-Allow-Origin.
How can I solve this?
Comments
Post a Comment