问题
I was trying to send a form details to a folder containing the php script to process and validated it using AJAX() method ,
But I am getting "Cross-Origin Request Blocked" error . I know this is cross browser problem but I am not able to find out a solution for this .
- Writing a Proxy server is one option . Can someone help me out with this I am very new to all this .
here is my code
<script>
*<![CDATA[*/
$(document).ready(function(){
$("#abusoForm #enviar").livequery("click", function(e){
e.preventDefault();
console.log("Click is working");
var hidden = $('#mensaje').val();
var category = $('#opcmarcar').val();
var name = $('#nombre').val();
var phone = $('#telefono').val();
var mail = $('#email').val();
var cf_mail = $('#confirma_email').val();
var k = ""
var z = "anotherdomain.com";
var otro = $('#otro_email').val();
var E = $("#abusoForm #enviar").val();
//Ajax call happening here
var vajx = $.ajax({
url: z,
type: "POST",
data: {
'h': hidden,
'c': category,
'n': name,
'p': phone ,
'm': mail,
'cm': cf_mail,
'otro1': otro,
"enviar": E,
async: false
}
}).responseText;
//Now I have to use the variable vajx to post a message about the submition of the form ;
$('#resultip').html(vajx);
})
});
/*]]>*/
</script>
I read this article http://www.html5rocks.com/en/tutorials/cors/ but cant understand much
. Another possiblity would be to use CORS but I am not getting it how to use the script to use with JQUERY function AJAX().
来源:https://stackoverflow.com/questions/23883261/making-ajax-call-result-into-cross-origin-request-blocked-error