I'm not sure why but I haven't really been able to find the right resource for this which helps me understand the best practice here, but say I have an application, that I want to make an Ajax request to another application.
Say app A's domain name is: www.example.com
, and I want to make a request to www.someapplication.com
Can I do something like this? (jQuery in this case)
$.ajax({
url: 'http://www.someapplication.com/items',
dataType: 'json',
data: "search=butter",
success: function(data){
console.log(data);
}
});
When I go the address (http://www.someapplication.com/items?search=butter&format=json
) in my browser it returns a 200 response and the content in the json format which I requested however when the above JS executes it receives a 200 response but no content.
Is this because my sever at someapplication.com is recognizing this as an XSS attack and denying a response?
One though I had is should the request go to a .js file? I've noticed this in the design of other applications, for example: http://www.someapplication.com/search.js
... err rather what is wrong with my concepts, am I missing something huge here about XSS, and Ajax?