Witam, pisze front w react i chciałem podpiąć pod button daną akcje :
import React, { Component } from 'react'
import $ from 'jquery';
export default class LoginButton extends Component {
send(){
$.ajax({
type: "GET", //typ połączenia na post
crossDomain: true,
dataType: 'json',
url: "http://localhost:80/aaa.php",
succes: ((json) => {
alert("POSZŁo")
}),
error: function (jqXHR, textStatus, errorThrown) {
alert("EJ")
},
})
}
render() {
return (
<div className = 'divButton'>
<button className = 'loginButton ' onClick = {this.send}> Zaloguj</button>
</div>
);
}
}
niestety wywala mi error:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.
Próbowałem zmienić typ zwrotu na JSONP aczkowliek dalej wywalało błąd. W skrypcie aaa.php mam w heders dodane Access-Controll-Allow-Origin.
Jakies porady?