How do i pass headers Parametesrs using JQuery Post

154 Views Asked by At

How do i pass headers Parameters using JQuery Post? i have this jquery post.

    $(document).on('submit',"#store_form", function(e) {
            e.preventDefault(); 

            $("#store_loader").fadeIn();

            term = $( this ).serialize(),
            url =  $( this ).attr( "action" );


            $.post( 'http://example.com/v1/user/create', term, function( data ) {
                  $( "#return_store" ).html( data );
            });



            $("#store_loader").fadeOut();
        });

i had this error:

XMLHttpRequest cannot load http://example.com/v1/user/create. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8888' is therefore not allowed access.

1

There are 1 best solutions below

2
Mandi On

If you are using PHP you can fix it adding something like this on your PHP script:

 header("Access-Control-Allow-Origin: *");