I'm making a GET request to a network camera that tells the camera to move in a certain way, e.g. pan, tilt, zoom, etc. I don't need a response from the camera's built-in web server, which is obviously a different host than the one where the calling JavaScript code resides. I was trying to make a jQuery $.ajax
request, which was not allowed due to the same origin policy. But when I change the 'dataType'
setting to 'jsonp'
it seems to work just fine in the latest versions of Firefox, Chrome, and Internet Explorer. Besides being a bit kludgy, are there any technical problems with this approach that will ever prevent it from sending the messages to the camera?
If your camera is just expecting a GET
request at that specific URL, then no, it won't make a difference. A JSONP request is essentially adding a pair of script tags to your document:
<script src="..."></script>
The callback
parameter is added to the URL so that when the resulting script is loaded, it executes a global callback function. jQuery hides this pretty well with $.ajax
, so you don't notice it.