getherbert / herbert

The WordPress Plugin Framework:
http://getherbert.com/
632 stars 94 forks source link

Allow HTTP method "OPTIONS" #71

Open ecoad opened 9 years ago

ecoad commented 9 years ago

Hello

As far as I can tell from Router.php, when Herbert receives a request using HTTP method "OPTIONS" for an Ajax call it creates an error as that's not a supported HTTP method.

How can I overcome this please?

Many thanks, Elliot

PrafullaKumarSahu commented 8 years ago

For me I am using ajax to send request to admin site, so instead of router.php I am using panel.php

I am using ajax for pagination here.

$panel->add([
    'type' => 'panel',
    'as'   => 'mainPanel',
    'title' => 'Plugin',
    'rename' => 'General',
    'slug' => 'plugin-admin-settings',
    'icon' => 'dashicons-chart-area',
    'uses' => __NAMESPACE__ . '\Controllers\PluginController@index',
    'post' => [
        'nextpage' => __NAMESPACE__ . '\Controllers\PluginController@nextpage',
    ]
]);

Here my panel slug is plugin-admin-settings , so the url to send request is

`  var url = '/test/wp-admin/admin.php?page=plugin-admin-settings&action=nextpage';`

and request I am sending is

       jQuery.post( url, request_input, function(response){
               console.log( response )
       }

I hope this will give you some idea.