2

I am sending a http POST request to a php file (located in another host), using ajax, inside a JavaScript file hosted at 000webhost.com. Even though I can see that the php file at the other host gets my request and acts accordingly, my script believes that the request failed and moves to the fail(function() part of the code.

Could this be a problem with my host?

Here is the code:

$.ajax({
    url: 'MyURL',
    data: 'MyData',
    type: 'POST',
    dataType: 'json'
}).done(function(jqxhr){
    //Part which I want to be executed.
}).fail(function(){
    //Part which that is executed.
}).always(function(){

});
Milad Rashidi
  • 1,026
  • 4
  • 14
  • 33
  • Have you looked at your JavaScript error console? Or looked at the error argument that gets passed to your fail callback? – Quentin May 12 '14 at 15:05

1 Answers1

-1

you need to set crossDomain to true for cross domain requests. look here for more information

http://api.jquery.com/jquery.ajax/

Guns
  • 2,598
  • 2
  • 19
  • 49
  • You should read your own link: *If you wish to force a crossDomain request (such as JSONP) on the same domain, set the value of crossDomain to true. This allows, for example, server-side redirection to another domain.* – Quentin May 12 '14 at 15:04