简体   繁体   English

Api 在 javascript 中使用 Ajax 调用给出错误

[英]Api call using Ajax in javascript giving error

i am getting error on calling ajax request with a code 422(unprocessible entity), i dont understand what is wrong with my code can someone help me to figure out the error我在使用代码 422(无法处理的实体)调用 ajax 请求时遇到错误,我不明白我的代码有什么问题有人可以帮我找出错误

         $.ajax({
            url: "/api/v3/email_exists",
            method: 'POST',
            data: {
              email: email_entered
            },
            success: function (response, status) {
                if (response.sent) {
                    showFlashMessage('Email Sent');
                    alert(response);
                }
                else {
                    showFlashMessage('An error occured, please try again latervrfg.', 'error');
                }
            },
            error: function (response, status) {
                showFlashMessage('An error occured, please try again later.', 'error');
            }
        }); 

url is returning either true or false in case of false it is giving status 422 url 返回 true 或 false,如果为 false,它给出状态 422

Try with a full URL e,g https://Path_to _the controller_method尝试使用完整的 URL 例如 https://Path_to _the controller_method

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

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