When to use json and when jsonp with jquery $.ajax?
ajax, cakephp, jquery, jsonp, php
Solution
Due to Same Origin Policy your ajax request is allowed only if: domain name, application layer protocol, and (in most browsers) port number of the HTML document running the script are the same
In your case the application layer protocol is different, that's why your script fails.
Possible solutions are:
JSONP, which has to be provided by the server
CORS, which is a more 'elegant' and clean solution, but is not yet fully supported by IE (IE7 doesn't support it, IE8 has some limitations)
Problem
In our site, Some pages are SSL and some are non-SSL. For Example: ``` http://www.example.com/search/patients https://www.example.com/patients ``` Now I am searching patients on `http://www.example.com/search/patients` page and send server request to `https://www.example.com/patients` via `jQuery $.ajax` function and `dataType=json`. I am unable to get data. Questions: Should I use `jsonp` when we request from `http` to `https` or `https` to `http` on same server? If I use SSL for both URLs then will it work with `dataType=json` only Thanks