简体   繁体   中英

url for ajax is not working

my ajax code is

$.ajax({
  url: "http://www.web-tutor99.com/ajax/template0.php",
  beforeSend: function() {
    $('div#divLoading').show();
  },
  complete: function() {
    $('div#divLoading').hide();
  },
  success: function(data) {
    var menuStyleSheets = $("head .menuStyleSheets");
    var i;
    for (i = 0; i < menuStyleSheets.length; i++) {
      //code
      $(menuStyleSheets[i]).remove();
    }
    $('<link rel="stylesheet" type="text/css" class="menuStyleSheets" href="styleSheets/styleSheet' + index + '.css" >').appendTo("head");
    $("#menuThm").remove();
    $(".showMenu").append(data);
    temp = Tempo.prepare('list');
    createMenu();
  },
  error: function() {
    alert("try another theme");
  },
  type: "GET",
})

and in the tamplate.php file i'm just echoing the html code but the ajax call is not fetching it showing the error alert, please help me, Thank you.

Ensure your Syntax is Correct / No Cross Origin Issues

Try removing the trailing , at the end of your AJAX call (after your type parameter). It's likely that your code is expecting another parameter that isn't there :

type: "GET",

Additionally, you will want to ensure that you are making this request from the same domain, otherwise you may encounter a cross-site "Access-Control-Allow-Origin" scripting error.

Use Your Developer Tools To Examine The Request

You may want to try using the Developer Tools (F12) within your browser and try examining the Request / Response content within the Network tab (seen below using Chrome) :

在此处输入图片说明

This should give you any specific server-side errors within the response if they are present.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM