简体   繁体   English

ajax 的 url 不起作用

[英]url for ajax is not working

my ajax code is我的ajax代码是

$.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.在 tamplate.php 文件中,我只是在回显 html 代码,但 ajax 调用没有获取它显示错误警报,请帮助我,谢谢。

Ensure your Syntax is Correct / No Cross Origin Issues确保您的语法正确/没有跨源问题

Try removing the trailing , at the end of your AJAX call (after your type parameter).尝试在 AJAX 调用结束时(在type参数之后)删除尾随, 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.此外,您需要确保您是从同一个域发出此请求,否则您可能会遇到跨站点“Access-Control-Allow-Origin”脚本错误。

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) :您可能想尝试在浏览器中使用开发者工具 (F12) 并尝试检查网络选项卡中的请求/响应内容(如下所示使用 Chrome):

在此处输入图片说明

This should give you any specific server-side errors within the response if they are present.这应该会在响应中为您提供任何特定的服务器端错误(如果存在)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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