const myState = {
users: [],
hospitals: []
}
const myReducer = (state = myState, action) => {
if( action.type === 'FETCH_DATA' ) {
return myState[action.storeType].concat(data)
}
return state
}
const fetchData = (url) => {
fetch(...).then(data => {
return {
type: "FETCH_DATA",
data: data.result,
storeType: data.type
}
})
}
$('#yourform').on('submit', function(e) {
e.preventDefault(); // для того, чтобы выключить стандартное поведение для формы
// your ajax code ...
})
if( window.innerWidth <= 640 ) {
var mobileScript = document.createElement('script')
mobileScript.src = 'http://example.com/mobilescript.js'
var mobileStyles = document.createElement('link')
mobileStyles.src = 'http://example.com/mobilestyle.css'
mobileStyles.rel = 'stylesheet'
mobileStyles.type = 'text/css'
document.head.appendChild(mobileScript)
document.head.appendChild(mobileStyles)
}