Solve the problem that ajax calls to php in the codeigniter framework cannot be accessed.

Source: Internet
Author: User
Solve the problem that ajax calls php in the codeigniter framework cannot be accessed. the loginview.html in the viewsfolder references the base. js in the js folder.
Ajax that calls php functions is included in base. js. The directory structure and code are as follows:

Google browser debugging error:
Failed to load resource: the server responded with status of 403 (Forbidden) is followed by the address
Http: // 127.0.0.1: 8088/teamlogging/application/controllers/Login. php/LoginActive? Username = 001 & password = wl
The following message is displayed when you click this address:

I don't know why this error is reported. please give me some advice.


Reply to discussion (solution)

var url = "index.php/login"

Var url = "application/controllers/Login. php ";

Var url = "application/controllers/Login. php ";
Haha, Boss Xu has never used ci

I tried both the methods on the first and second floors and reported this error.
Get: http: // 127.0.0.1: 8088/teamlogging/application/controllers/Login. php/LoginActive? Username = 001 & password = wl 403 (Forbidden)

var url = "http://127.0.0.1:8088/login/loginActive"

I still cannot report the same error. I don't think it's the path.

I still cannot report the same error. I don't think it's the path.
Can you directly enter this address in your browser to access it?

To test, I created a new a.html under the viewsfolder and added the test in LoginView. thml.
Click this link to skip to a.html. Pop-up page prompt
Forbidden
You don't have permission to access/teamlogging/application/views/a.html on this server
This means that access is not allowed, indicating that the address is correct but not allowed, that is, the permission issue.

Direct access is not allowed.

You still don't know about the access mechanism of mvc. you can go back to the ci Manual. for example, a.html, you must first create a class for a to access through classA.
The real access is 127.0.0.1: 8080/index. php/classA/functionB (classA is the controller functionB is the controller classA method)

Whether or not I have used ci
The principle is always the same!

Http: // 127.0.0.1: 8088/teamlogging/application/controllers/Login. php/LoginActive? Username = 001 & password = wl
In teamlogging/application/controllers/Login. php/LoginActive is the path
Because there is no file name, no error will be reported if at least teamlogging/application/controllers/Login. php/LoginActive/index. php exists.
What you should actually access is teamlogging/application/controllers/Login. php.

Http://codeigniter.org.cn/user_guide/general/controllers.html
Let's take a good look at the principles of ci MVC.

Thank you, boss. the method on the first floor is correct. I started to modify the url in the editing tool, but not because the browser contains the cached js url. Just now, after debugging and opening the wrong link, go to JS and check whether the result is the original URL. I was dizzy in an instant .... Damn cache. Clear the cache.
Thank you again, boss.

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.