jquery - Load certain pages in a modal box on page load -


i have built simple modal using jquery takes url , loads using ajax method , inserts response html div display on screen in design of modal box. simple stuff!

however these pages actual urls e.g. domain.com/posts/add , can accessed directly via browser , not clicking link within app. prefer displayed in modal @ times if user types url address bar. make if request not ajax redirect them homepage or show 404 prevent happening.

i prefer load these pages in modal should user access them directly via http in same way chrome store e.g. https://chrome.google.com/webstore/detail/pjkljhegncpnkpknbcohdijeoejaedia

how though? without having messy javascript? ideas or suggestions appreciated. please note should work proper app in allows user use , forth buttons , modal should appear , disappear

as modal code use...

it simple , example of how looks (note mine more robust this, code purely example of simplicity)

$('.ajax-link').click(function(e){  e.preventdefault;  $.ajax({  url: $(this).attr('href'), success: function(response) { $('<div id="modal">' + response + '</div>').appendto('body'); } }); 

});

first of all, use .get() instead.

second, if using full urls domain, due security issues mentioned in link above:

due browser security restrictions, "ajax" requests subject same origin policy; request can not retrieve data different domain, subdomain, or protocol.

unless using jsonp, doubt are.


Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -