When jsonp is used to complete cross-origin requests, but the request link is a js file, the request always reports an error in that js. how can this problem be solved? -Php Tutorial

Source: Internet
Author: User
It is okay to change the link to php. & Quot; $. ajax ({type: & #39; GET & #39;, async: false, url: & quot; app. veishu. comjsonpcategoriesall. js & quot;, dataType: & quot; jsonp & quot;, success: function (data) {alert (& quot; success & quot ;); alert (data [0]); vardataHtml & quot; jsonpjs file php

It is okay to change the link to php.

    $.ajax({        type:'GET',        async:false,        url:"http://app.veishu.com/jsonp/categories/all.js?1.1.29",        dataType:"jsonp",        success:function(data){            alert("success");   //         alert(data[0]);   //         var dataHtml=""   //         for(var i=0; data.length;i++){   //             dataHtml+="
  • "; } $(".list").html(dataHtml); }, error:function(){ alert("ajax is error"); } });
    This ajax will not enter error or success. An error is reported in the js of that link. If you change the link to php, success is successfully entered. However, the link to this js file is directly opened in the browser, and json can appear. What's going on? In addition, how can I convert unicode characters into JavaScript files in a browser! [Picture description] (http://img.ask.csdn.net/upload/201504/25/1429951452_561399.png)

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.