Topic: ReactJS

Cross Header Access Control Allow Origin missing 0

Cross Header Access Control Allow Origin missing

Cross Header Access Control Allow Origin missing

In this Post We Will Explain About is Cross Header Access Control Allow Origin missing With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to Access Control Allow Origin Error SolutionExample

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://pakainfo.com/api/index.php/driverlist/0. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

1.cross-origin request blocked: (reason: cors header ‘access-control-allow-origin’ missing).
2.this can be fixed by moving the resource to the same domain or enabling cors.
3.cors header ‘access-control-allow-origin’ missing jquery , Angularjs or any ajax call

In this post we will show you Best way to implement reason cors header ‘access-control-allow-origin’ missing angularjs, hear for no access control allow origin header is present jquery ajax originwith Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

AngularJS $http, CORS and http authentication

 $http({
        url: 'http://www.Pakainfo.com/api/v1/get_profile',
        method: "POST",
        data: {username :  ravi dholakiya },
        withCredentials: true,
        headers: {
                    'Content-Type': 'application/json; charset=utf-8'
        }
    });

Nodejs : Access-Control-Allow-Origin

server side you have to put headers nodejs

app.all('*', function(get_request, result,next) {

    var get_response = {
        "AccessControlAllowOrigin": get_request.headers.origin,
        "AccessControlAllowHeaders": "Content-Type,X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5,  Date, X-Api-Version, X-File-Name",
        "AccessControlAllowMethods": "POST, GET, PUT, DELETE, OPTIONS",
        "AccessControlAllowCredentials": true
    };

    result.header("Access-Control-Allow-Credentials", get_response.AccessControlAllowCredentials);
    result.header("Access-Control-Allow-Origin",  get_response.AccessControlAllowOrigin);
    result.header("Access-Control-Allow-Headers", (get_request.headers['access-control-request-headers']) ? get_request.headers['access-control-request-headers'] : "x-requested-with");
    result.header("Access-Control-Allow-Methods", (get_request.headers['access-control-request-method']) ? get_request.headers['access-control-request-method'] : get_response.AccessControlAllowMethods);

    if ('OPTIONS' == get_request.method) {
        result.send(200);
    }
    else {
        next();
    }

});

config.xml file


.htaccess : Access-Control-Allow-Origin

AngularJS, PHP Restful Cors issue : My .htaccess:

# Cors
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Access-Control-Allow-Origin"
Header always set Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"

PHP : Access-Control-Allow-Origin

we are missing CORS settings on your simple PHP headers:

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: Origin, Content-Type, Accept, Authorization, X-Request-With');
header('Access-Control-Allow-Credentials: true');

Example

I hope you have Got What is Access Control Allow Origin Error Solution And how it works.I would Like to have FeadBack From My Blog(Pakainfo.com) readers.Your Valuable FeadBack,Any Question,or any Comments abaout This Article(Pakainfo.com) Are Most Always Welcome.

Access Control Allow Origin http set Headers 0

Access Control Allow Origin http set Headers

Access Control Allow Origin http set Headers

Simple Include headers Uing CORS solution (Cross-origin resource sharing)

Welcome to the In Pakainfo.com website! You will Step By Step learn web programming, easy and very fun. This website allmost provides you with a complete web programming tutorial presented in an easy-to-follow manner. Each web programming tutorial has all the practical examples with web programming script and screenshots available.For Access Control Allow Origin http set Headers

Access-Control-Allow-Origin – Name of the each domain allowed access control all for cross domain requests. * (* means all domain allowed)indicates all domains are allowed.
Access-Control-Allow-Methods – List of (GET, PUT, POST, DELETE, OPTIONS)HTTP methods can be used here domains during request.
Access-Control-Allow-Headers – List of (GET, PUT, POST, DELETE, OPTIONS)HTTP headers can be used here domains during request.

In PHP : “no ‘access-control-allow-origin’ header is present on the requested resource web api”

The Soltution of the no ‘access-control-allow-origin’ header is present on the requested resource web api in PHP.

// here include this three statement
header('Access-Control-Allow-Origin: *');  //all the methods access code
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS'); // all the resource and request get
header('Access-Control-Allow-Headers: Content-Type, Content-Range, Content-Disposition, Content-Description');

simple Below the sample code which handles Cross Domain AJAX POST requests: post.php

CORS works fine in all the latest browsers, but IE8 and IE9 don’t support this.

In order to use XDomainRequest in IE, request must be:
a). Only GET or POST
When Posting, the data will always be sent with a Content-Type of text/plain
b). Only HTTP or HTTPS
Protocol must be the same scheme as the calling page
c). Always asynchronous

Step 1). Add the script in

<script type='text/javascript' src="http://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.1/jquery.xdomainrequest.min.js"></script>

Step 2). You need to set contentType value text/plain in $.ajax request.

 var contentType ="application/x-www-form-urlencoded; charset=utf-8";
 
if(window.XDomainRequest) //for IE8,IE9
    contentType = "text/plain";
 
$.ajax({
     url:"https://pakainfo.com/php/post.php",
     data:"name=king&age=28",
     type:"POST",
     dataType:"json",   
     contentType:contentType,    
     success:function(result)
     {
        alert("here Display all the Data from Server"+JSON.stringify(result));
     },
     error:function(jqXHR,textStatus,errorThrown)
     {
        alert("Error display :You can not any data send Cross Domain AJAX simple requests: "+errorThrown);
     }
    });
	

Below is the sample code, works in all the browsers.

<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script src="jquery.min.js"></script>
<script type='text/javascript' src="http://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.1/jquery.xdomainrequest.min.js"></script>

</head>
<body>
 
<input id="get_methoddata" type="button"  value="Data Send X  -> Method GET"/>
<input id="post_methoddata" type="button" value="Data Send X -> Method POST" />
 
<script>
$(document).ready(function()
{
    var data_contentType ="application/x-www-form-urlencoded; charset=utf-8";
 
    if(window.XDomainRequest)
        data_contentType = "text/plain";
 
    $("#post_methoddata").click(function()
    {
        $.ajax({
         url:"https://pakainfo.com/php/post.php",
         data:"name=johan&age=28",
         type:"POST",
         dataType:"json",   
         contentType:data_contentType,    
         success:function(result)
         {
            alert("here Display all the Data from Server"+JSON.stringify(result));
         },
         error:function(jqXHR,textStatus,errorThrown)
         {
            alert("Error display :You can not any data send Cross Domain AJAX simple requests: "+errorThrown);
         }
        });
 
    });
 
    $("#get_methoddata").click(function()
    {
        $.ajax(
        {
         url:"https://pakainfo.com/php/get.php?name=johan&age=48",
         dataType:"json",
         contentType:contentType,
         success:function(result)
         {
            alert("all the Data from here display Server"+JSON.stringify(result));
         },
         error:function(jqXHR,textStatus,errorThrown)
         {
             alert("Error display :You can not any data send Cross Domain AJAX simple requests: "+errorThrown);
         }
        });
 
    });
 
});
</script>
</body>
</html>

post.php source code:

<?php
// here include this two statement
header('Access-Control-Allow-Origin: *'); 
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
 
 //check condition headers set or not
if(isset($HTTP_RAW_POST_DATA)) {
  parse_str($HTTP_RAW_POST_DATA,$arr); 
  $arr['data_extra']='task 1.your request POST Request from Pakainfo.com';
  echo json_encode($arr);
}
else
{
    $_POST['data_extra']='task 2.your request POST Request from Pakainfo.com';
    echo json_encode($_POST);
}
?>

Example

header set access-control-allow-origin multiple domains | cross domain ajax request,cross domain ajax request jquery | no access control allow origin header is present jquery ajax origin

ReactJS Simple Table Component – React Tables 0

ReactJS Simple Table Component – React Tables

ReactJS Simple Table Component – React Tables

In this Post We Will Explain About is ReactJS Simple Table Component – React Tables With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to A Bootstrap table built with React.js Example

In this post we will show you Best way to implement ReactJS: Simple Table Component, hear for ReactJS with Table or Datatable with export options with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

React Tables

In this Example,First of all Add or Include External Libs Like as a(jQuery, css etc..), and then create a simple index.php or index.html page.After that crate a simple javascript file like as a index.js or main.js, It is also add your web-application First Header Part to some priority set.After that Include your relevant CSS Class.

Include External Libs

http://facebook.github.io/react/js/jsfiddle-integration.js
https://cdnjs.cloudflare.com/ajax/libs/react/0.13.0/JSXTransformer.js
https://cdnjs.cloudflare.com/ajax/libs/react/0.13.0/react-with-addons.js
https://code.jquery.com/jquery-2.1.3.min.js
https://code.jquery.com/ui/1.11.4/jquery-ui.min.js
https://code.jquery.com/ui/1.11.4/themes/black-tie/jquery-ui.css

index.html

<div id="live_example"></div>

index.js

var cols = [
    { key: 'userfname', label: 'User First Name' },
    { key: 'userlname', label: 'User Last Name' }
];

var data = [
    { id: 1, userfname: 'jaydeep', userlname: 'Gondaliya' },
    { id: 2, userfname: 'Ramesh', userlname: 'Mehata' }
];

var Table = React.createClass({

    render: function() {
        var tablehead = this.generateHeaders(),
            dataRowcom = this.generateRows();

        return (
            <table>
                <thead> {tablehead} </thead>
                <tbody> {dataRowcom} </tbody>
            </table>
        );
    },

    generateHeaders: function() {
        var cols = this.props.cols;  //simple [{key, label}]

        // generate simple our header (th) cell components
        return cols.map(function(liveColDta) {
            return <th key={liveColDta.key}> {liveColDta.label} </th>;
        });
    },

    generateRows: function() {
        var cols = this.props.cols,  // [{key, label}]
            data = this.props.data;

        return data.map(function(product) {
            //Pakainfo.com handle the column data within each row
            var tablecells = cols.map(function(liveColDta) {

                // liveColDta.key might be "userfname"
                return <td> {product[liveColDta.key]} </td>;
            });
            return <tr key={product.id}> {tablecells} </tr>;
        });
    }
});

React.render(<Table cols={cols} data={data}/>, document.getElementById('live_example'));

ReactJS Simple Table Component

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Example

I hope you have Got What is React Table – Table UI Component for React JS And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.