简体   繁体   English

jQuery .load()代码初始化页面

[英]jQuery .load() codeigniter page

I am trying to build an Ajax suggestion feature within codeigniter using jQuery. 我正在尝试使用jQuery在codeigniter中构建Ajax建议功能。 However, when I am using the .load() function within jQuery I cannot find a way to call the controller, I am calling it as so: 但是,当我在jQuery中使用.load()函数时,无法找到一种调用控制器的方法,我这样调用它:

$("#sugresultcontain").load('http://localhost/ajaxtest/suggest #loadsuggest');

However, the content does not load. 但是,内容不会加载。 I then tried to use: 然后,我尝试使用:

$("#sugresultcontain").load('http://localhost/ajaxtest/application/views/ajaxref/suggest.php #loadsuggest');

And as expected, again this did not work as I need to make a call to the controller and not just the view itself. 而且正如预期的那样,由于我需要调用控制器,而不仅仅是视图本身,所以这再次不起作用。

So my question is, how can I use the .load() AJAX function to call to the controller that outputs suggest.php. 因此,我的问题是,如何使用.load()AJAX函数来调用输出suggest.php的控制器。

If more detail is needed, please just ask. 如果需要更多详细信息,请询问。

When you are having problems with AJAX requests, you can see server's response 当您遇到AJAX请求问题时,您可以看到服务器的响应

  • in Google Chrome and in Internet Explorer by pressing F12 on tab Network 在Google Chrome和Internet Explorer中,按“网络”标签上的F12
  • in Firefox by pressign CTRL+Shift+K 在Firefox中,通过按Ctrl + Shift + K

If you have allowed displaying errors, it will be there. 如果您允许显示错误,它将在那里。

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

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