I have use modal for user sign up and its working correctly when user click on register link the modal popup load perfectly now i am making comment box where user can comment on pictures and if user is not login i want to load the same popup modal which is bind with register link some how i am successful but the error is that the load() function load the entire page for me on the same page i am totally confuse. here is my coding .
$("#button").click(function(){
var user=$("#username").val();
var message=$("#form-s-t").val();
if(user != ""){
if(message != ""){
$.ajax({
type:"post",
url:"retriveing.php",
data:"name="+name+"&message="+message+"&action=addcomment",
success:function(data){
showComment();
}
});
$("#form-s-t").val('');
}
else {alert("you can not post empty comments");}
}
Here in else portion i am loading the popup.
else{
$('.topopup').load("#toPopup");
}
});
});
The popup which loads with register link is this.
User which is not login want to comment it load the page twicly and oppositly as shown in picture.
There is no need of load() function if the model resides in the same page . try to trigger the register link which can be done like that.
Remove the load function in your else portion and just write the code I have give below.
$('.topopup').trigger("click");
.topopup
is a id of register link and you want to load this popup when user is not sign in and want to comment. I hope it will work for you. if the model resides in the same page.
From you screenshot, you send the wrong argument to the server.
$('.topopup').load("#toPopup");
// you just load "/#toPopup" page from the server
// and the server return a new page to you
// then jQuery update '.topopup' with the new
// page
You are loading an anchor, so the same page is getting injected into the elements with class .topopup. Just check your register button's onclick function and use else { thatFunction(); } if you want to recreate the same behaviour. [Also try using retrieving.php as a filename.]
To clarify: load("#toPopup") is equiv. to load(currentURL+"#toPopup"). First parameter is an URL string, not a selector string.
Related
I try to find Q&A related to my question. But I couldn't find. I have created a code where if user click double or multi click at single link then he will redirect to error page.
My Code is
<script>
var doubleClick = false;
function myWillPageRedirect() {
if(!doubleClick) {
doubleClick = true;
window.open("errorPage.html");
}
}
</script>
But this is not working. Why?
I want to create a secure page generally we can see in some bank or financial website.
I want to create 'if user click window back button then he will redirect to error page.' OR if if click refresh button then same action will perform and redirect to error page. ..
If this all code can make in Linux server backend code. It would be great.
Please help. I am not saying to some create code for me , I am asking for help to some correct my code above or bit extra help to make them secure.
Thank you .
HTML:
Double-click me
JS:
if(performance.navigation){ //Check if the page was refreshed
if( performance.navigation.type === performance.navigation.TYPE_RELOAD ){
myWillPageRedirect();
}
}
function myWillPageRedirect() {
window.open("errorPage.html");
}
window.onhashchange = function() { //Check if the url has changed (in case of pressing back button)
myWillPageRedirect();
}
More infos about Performance.navigation
So basically i have everything ready, but i'd like a pop-up message appear after the user redirect to another page.
so i am currently use jquery
$('#btn_save').click(function (){
$('#message-box').slideDown('slow').delay(3500).slideUp('slow');
});
I do not know if i should use ajax instead, i know i may use route and if(session) to do it but i am new to ajax and will happy to got an example as reference.
Many thanks
UPDATE 1:
This the part of my submit button which redirect the user after submit:
var $btn_save = $("#btn_save");
$btn_save.click(function () {
//todo form validation
if(!$(".sa-alert-name-existed").hasClass('hidden')){
return
}
$.post(api_submit, postData).done(function (data) {
location.href = "/buzz#tab_pane_fbpage";
});
Then we should come to the js part, which popup a message when onclick the submit button
$('#btn_save').click(function (){
$('#message-box').slideDown('slow').delay(3500).slideUp('slow');
});
enter code here
I have a Subscribe form that only opens through Javascript on a link in a page. It is located at https://pixelark.com/cscc (under 'or signup via email to receive our weekly bulletin. Click here').
The problem is that it requires an extra click for someone to see this subscribe form. First click to access the page and the second click to access the form.
Is it possilbe to set it up in the a link such that it will goes to the page and open the form automatically?
Thanks
Why don't you check for parameters in your URL and in your Document.ready event
something like https://pixelark.com/cscc?page=register or https://pixelark.com/cscc#register
$(document).ready(function(){
if ($('.slider img').length == 2) {
var global_rotator = setInterval( "rotate()", 5000 );
}
// insert code here to check location parameters
});
here is an example on how to check location parameters
without using jQuery or something else, add a script tag:
<script>
(function() {
window.onload = function() { show_signup_form('426'); })
})(window);
</script>
I have a login screen which the user logs in using Jquery and AJAX. That's fine. Now what I want is that if the user logs in correctly, I want to load another page.
I tried using document.location = "home.html"; but that refreshes my page. What I want is like that transition that normally we have when we click on tag like
<a href="SchoolMaterials.html"> <!-- this does not refresh -->
I don't know if I explained myself clearly.
Thanks
It will be better to load the page in your callback function of successful login with:
$("#the_div_container_for_new_page").load("SchoolMaterials.html")
UPDATED:
it is something like this:
$(document).ready() {
function login() {
//post with ajax to login
$.post(......, function(result){
if (result.success) {
// load some page after successful login.
$('#id_of_container_div').load("thepage.html");
return;
} else {
// handle error
}
})
}
}
window.location is just what you need. You can also create an anchor element using jQuery and simulate a click on it :
$("<a href='your url'></a>").click();
But i wouldn't recommend that, it's better to post your data to the server and redirect to the page you want.
I have a problem. I have a page that when you click a button, a popup with a form is shown. So, I complete some data and I submit. What I want to do is, to submit the form, close the form and refresh the parent page. I don't want to do it with AJAX.
The problem is that in my parent page I have to refresh content with the input information of the form.
So when I refresh, sometimes the data is shown and sometimes not. Do you know why this could happen?
I just use onsubmit="refreshParent()" in my form. The info is stored always in my database, so I think the problem may be that sometimes the refresh catches the new info and sometimes not.
function refreshParent() {
window.opener.location.reload();
window.close();
}
I use this to reload the page that opened a popup window:
<script language="JavaScript">
<!--
function reloadParentPage() {
window.opener.location.href = window.opener.location.href;
if (window.opener.progressWindow) {
window.opener.progressWindow.close()
}
window.close();
}
//-->
</script>
By the way, the code above is called by a link or button in the popup page.
You have a race condition between the script doing the insert and the script reloading the parent.
The solution is to call refreshParent on the page after the submit - that way you know the data is in the database. You don't even have to do it on document ready - return a stub page that just defines and calls refreshParent in the head tag.
In PHP when you run post script, at the end, include this code :
echo '<html><script language="javascript">
parent.location.href="http://'.$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"].'"; // or any other url
</script></html>';
This will output a javascript that will reload the windows.