通过jQuery进行AJAX调用

I've a problem with an AJAX GET call using jQuery.

Here's my code:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> 
<script>
$(document).ready(function() {    

    $.ajax({
        url : "http://localhost:8080/aplus-framework-webapp/reportServlet?",
        data: "STAT_START_DATE=20131001&STAT_END_DATE=20131031&CAMPAIGN_START_DATE=2013-10-31&CAMPAIGN_END_DATE=2013-10-01&ORDER=Stato",
        dataType: "json",
        type: "GET",
        processdata: true, 
        success : function (data) {
            alert("IN");
        },
        error : function (richiesta,stato,errori) {
            alert("NOT SUCCESS");    
        }
    });// end ajax call
}); // end ready
</script>

The servlet reportServlet is my Java servlet running in localhost that return a JSON:

{"url":"http://d1p0y6pjyasam8.cloudfront.net/PGBANNER/text/20131105100823campaigns.csv"}

I test the page in local but I always see the alert reporting 'NOT SUCCESS'.

I'm new to JS, anyone have any idea on which could be my mistake?

Thanks

Alessio

Try removing the question mark at the end of your url

I assume you mean with 'page in local' that you try this in a local file on your hard-drive. This is disabled due to security reasons in mainly all browsers. You can find further information how to disable this in Google Chrome for development purposes here:

http://opensourcehacker.com/2010/11/29/disabling-cross-domain-security-check-for-ajax-development-in-google-chrome/

Are Sure Your servlet return header json ?

If the website you're requesting from and the servlet you're requesting on do not have the same port (for instance 80 and 8080), it will break the Same Origin Policy.

See this stackoverflow question form more information and answers.