HTTP 405 API jQuery Ajax PHP - javascript

我正在尝试在myewellness.com上添加成员

我在wordpress网站上使用jquery和php,我必须收集用户的详细信息并将其添加到myewellness.com
这是他们api文档的链接:
http://www.mediafire.com/view/pr6s7isht9ihdao/API-Services-Documentation-v2.0-1.pdf

但是我在chrome上得到了这个:

OPTIONS https://api.myewellness.com/api/v1/services/membership/create send @ jquery.js?ver=1.11.2
(index):1 XMLHttpRequest cannot load https://api.myewellness.com/api/v1/services/membership/create. Response for preflight has invalid HTTP status code 405
(index):1509 Failed: [object Object]

并且在狐狸上未启用CORS错误,

这是我的js:

jQuery.noConflict();
    (function( $ ) {
      $(function() {
        $("#register_form").submit(function(){
            console.log("Wellness API Initiated!");

            var api_user_name = $("#user_name").val();
            var api_user_email = $("#user_email").val();
            var api_payment_first_name = $("#payment_first_name");
            var api_payment_last_name = $("#payment_last_name");
            var api_user_password = $("#user_password").val();
            var api_client_address_one = $("#client_address_one").val();
            var api_client_address_two = $("#client_address_two").val();
            var api_client_city = $("#client_city").val();
            var api_client_state = $("#client_state").val();
            var api_client_zip = $("#client_zip").val();
            var api_client_gender = $("#client_gender").val();
            var api_client_home_phone = $("#client_home_phone").val();
            var api_client_cell_phone = $("#client_cell_phone").val();
            var api_client_work_phone = $("#client_work_phone").val();
            var api_client_birth_date = $("#client_birth_date").val();

            $.ajax({
                type: "POST",
                url: "https://api.MYEWELLNESS.com/api/v1/services/membership/create",
                /*headers: {
                    'Authorization':'Basic Vml0YWxhbGVydA==:MTI5OTky',
                    'Content-Type':'application/json'
                },*/
                data: "user_name="+api_user_name+"&password="+api_user_password+"&first_name="+api_payment_first_name+"&last_name="+api_payment_last_name+"&address1="+api_client_address_one+"&address2="+api_client_address_two+"&city="+api_client_city+"&state="+api_client_state+"&country=US&zip="+api_client_zip+"&email="+api_user_email+"&phone="+api_client_home_phone+"&work_phone="+api_client_work_phone+"&cell_phone="+api_client_cell_phone+"&gender="+api_client_gender+"&birthdate="+api_client_birth_date,
                datatype: "json",
                beforeSend: function(xhr) { xhr.setRequestHeader("Authorization", "Basic " +"Vml0YWxhbGVydA==:MTI5OTky"); },
                success: function(msg){
                    console.log("Success: "+msg);
                },
                error: function(error){
                    console.log("Failed: "+error);
                }
            });
            console.log("API Fire Complete!");
            return false;
        });
      });
    })(jQuery);

参考方案

他们的服务器未授予您指示其他浏览器访问其API的权限。

无论如何,您都不应该这样做-否则,您会将API密钥移交给所有访问者!

而是使用PHP从您的服务器发出API请求。您可能需要查看cURL library来执行此操作。

在访问另一页面后保留浏览器滚动位置 - php

我正在使用JS,JQuery和PHP,试图解决无限滚动问题。问题是,如果您在页面上滚动很长一段时间,并且用ajax加载了更多页面,然后单击链接转到新页面,那么在使用浏览器时如何自动转到旧页面中的同一位置新页面上的返回按钮?。新页面使用ajax滚动加载。 php参考方案 我想出的解决方案是在离开页面之前,将每个页面与相关数据一起存储。需要以下信息来保持滚动位置…

验证php中的javascript对象 - php

在我的用户界面中,用户可以构建一些javascript对象,例如:var box = { "width": "100px", "height": "200px", "click": function () { alert("You clicked t…

和字符中断通过PHP接收JSON - javascript

我有一个包含更多对象的数组。如果一个对象包含&字符,则php不会接收&之后的每个对象。可能是什么问题?这就是阿贾克斯xmlhttp.open("POST", "get.php"); xmlhttp.setRequestHeader("Content-Type", "application/…

jQuery val函数在隐藏字段上不起作用? - javascript

这是我的HTML代码:<div style='display:none;' id='allformid'> <div> <form action='#'> <input type='text' name='name' …

如何隐藏您网站的javascript文件? - javascript

我在main.js文件中编写了许多使用ajax调用PHP函数的函数。问题在于,任何人都可以通过查看页面源代码来查看我的逻辑和内部称为php的网站的文件名。我应该如何防止人们查看我的JavaScript文件? 参考方案 可以混淆Javascript,但是没有什么可以阻止客户端执行在代码中查看网址字符串,或者只需检查HTTP请求本身即可确定正在攻击的URL。这加…