javascript - how to navigate one page to another page when click on button/link in html5 -


i have link/button in html page . when click button have populate page data model popup in current page. used bootstrap model popup . possible without call server navigate page , wihtout jquery/any server side technologies. need used simple java script this.

if want populate modal information, , want information persist (not append html on it). yes, you'll need in manner communicate server can update content.

actually there's no way populate persistent content, given user action, without talking server. (i.e. refresh page , still there see)

since asked html5 solution, have fetch api. fetch designed easier , broader xmlhttprequest. quote mdn:

the fetch api provides interface fetching resources (e.g., across network.) seem familiar has used xmlhttprequest, new api provides more powerful , flexible feature set.

my guess want post information on modal. supposing want send form data modal: you'll want use this:

fetch('http://your-website-goes-here.com/submit-data', {   method: 'post',   body: json.stringify({     name: document.getelementbyid('name').value     email: document.getelementbyid('email').value     message: document.getelementbyid('message').value   }) }) 

notice not browsers supports fetch, uses es6 promises. nothing polyfill wouldn't solve. more on can use. see fetch , promise support.

for further info fetch, i'd recommend following:


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -