简体   繁体   中英

Jquery - Getting 403 error when submitting form via ajax

I have a php page called form.php. When you go to this page it shows a form, when that form is submitted I have jquery code that posts the form to itself via ajax. This works for other pages, however this specific page/code is giving me a 403 error when the page is submitted. The main difference is the other pages that work are located in a sub folder while form.php is in the root directory. Here is the jquery code:

$.ajax({
type:'POST',
cache:false,
url:'/form.php?action=add',
data:formData,
dataType:'json',
success: function(data) {})
});

I understand this is a server error, my question is why would it fail pointing to itself via the root folder but not fail if posted to a page in a sub folder?

尝试使用

url:'.../form.php?action=add',

使用完整的URL到文件http://blah.com/form.php

Ok I figured it out. One of the fields I was storing 2 variables in one value like so:

1<>2

I guess the <> part was triggering some issues, once I removed that it worked without any issues. Thanks everyone for the help!

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