简体   繁体   English

jQuery Ajax调用在Chrome浏览器中不起作用

[英]jQuery Ajax call not working in Chrome Browser

jQuery Ajax call not working in Chrome Browser. jQuery Ajax调用在Chrome浏览器中不起作用。

my code :- 我的代码:-

function memories(pageName)
{
   $.ajax({
   type: "POST",
   url: pageName,   
    success: function(html){
        $("#page").load(pageName); 

   }
 });    
}

You're calling load , but not passing in a URL. 您正在调用load ,但没有传递URL。 load is for loading content from a URL and then applying it to an element. load用于从URL加载内容,然后将其应用于元素。 You either want to use it without ajax , or you want html . 您要么想在没有ajax情况下使用它,要么想要html

Eg, either: 例如:

function memories(pageName)
{
    $("#page").load(pageName);
}

or (more likely, as you've used POST, although as you haven't supplied any params it's not clear): 或(更有可能,因为您使用过POST,但由于您未提供任何参数,因此不清楚):

function memories(pageName)
{
   $.ajax({
   type: "POST",
   url: pageName,   
    success: function(html){
        $("#page").html(html); 

   }
 });    
}

You are using load() where you should be using html() to set the contents of an element: 您正在使用load() ,而应该使用html()来设置元素的内容:

function memories(pageName)
{
   $.ajax({
       type: "POST",
       url: pageName,   
       success: function(html){
           $("#page").html(html); 
       }
   });    
}

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

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