how to make href linkable with ajax without reload the page - ajax

I have this link:
follow
when the user click on its just refresh the page and do the follow function.
it there is to do the follow without reload the page?
sorry I am so week in Ajax, and really need help

You do not need Ajax to stop the browser from reloading.
Just change return true to return false, and you will cancel the default browser behaviour of following links.
If the followUser function makes an Ajax request or not won't make a difference.

Related

how to create middleware in laravel

I have created the project which has login page login.blade.php which has only Regno to login-in.
once it login is the success it will redirect to home.blade.php and it followed by 4 more pages when clicking of next button in each page
page2.blade.php,page3.blade.php,page4.blade.php,page5.blade.php and finally, it should redirect to login page itself. The problem is the browser back button should not allow it to go back to the previous page.
can anyone suggest me how to create middleware for this?
thank you.
The browser's back button is not controlled by the server, where Laravel runs. There is no way for you to block it or interact with it in any way inside your PHP code.
What you can do is send XMLHHTTPRequest (XHR) with JavaScript. They ensure that on a button click you will stay on the same page in the browser and then your JS-code can read the server response (your rendered page templates) and replace the current content with the one from that response. You can read more on this when you google for AJAX, e.g. this article: https://www.sitepoint.com/use-jquerys-ajax-function/
Read this thing. I once implemented in the same way. By setting cache control in response header.
https://stackoverflow.com/a/51821808/10239067

Facebox Fails When Loaded via AJAX

I have a very simple HTML page at http://bit.ly/1eaSnKt
The first line is a functioning Facebox link. Note that, when clicked, it opens the FaceBox popup perfectly.
The second line is a similar link, but exists on a different HTML page which is pulled via AJAX (see source). For some reason, when clicked, it fails to open the FaceBox popup. Does anyone have a clue why this is failing? Thanks.
When your page loads, on Document ready, you are attaching the behaviors to the items in the page.
With the Ajax load, it loads the items after the document is ready, and there jQuery has attached the behaviors... missing your new content.
You need to attach those behaviors after the ajax is successful.
So after the ajax load, use a callback, or a closure to do this
$('a[rel*=facebox]').facebox({
loading_image : 'facebox/loading.gif',
close_image : 'facebox/closelabel.gif'
})
Hope that makes sense.
Thanks all. I actually found the solution here - https://github.com/dator/facebox/commit/5ce6a75927d81b9fff1eeff9b933f0ad93f12801

Facebook like button's iframe not expanded after ajax request

I'm adding a facebook share button to each post on a Wordpress (Using Facebook Share Button New plugin), it works ok for each post/page except when i'm loading them trough ajax, the result it's a normal Facebook like button but the popup (to write a comment) appears inside the button it is not expanded.
To check go to: http://iwanttobeher.com/ and then click on any face at the bottom of the page, then test the like button and you'll see what happens.
I don't know what to do, i tried to FB.XFBML.parse() after loading the content but the result is the same.
Switching to HTML5 didn't help in our case. What did was to remove the FB object just prior to new content being inserted into the page via Ajax:
delete FB;
wrapper.html(response.data);
We reload full pages via Ajax and so new page content recreates the FB object and re-initializes XFBML anyway. Not sure if this workaround would work if we reloaded only parts of the page though.
The original answer is here.
I've managed to fix it by changing the implementation to HTML5 instead Iframe or XFBML using Facebook's tool to generate like buttons: https://developers.facebook.com/docs/reference/plugins/like/

Rails 3 - automatic AJAX request

I am struggling with a problem about automatic AJAX load of page. I have normal static page, where is a link. After click on this link I will call an AJAX request for loading a data.
This works me. I try now to add next functionality - I would like after load a normal static page to load that AJAX data automatically - is possible to do somehow?
I tried it to do whole afternoon, but I still don't know, how to do it...
So, I will very grateful for every hints, how to do it... Thank you so much.
Make your Ajax call in your jQuery ready function, e.g.:
<script>
$(function() {
$.ajax(...);
});
</script>

Is there a way to refresh the entire page after making a ajax call

Can I refresh the whole page after making ajax calls. kindly check my code on this link for details. Actually I am saving on different server and I am making calls from different url and to see the changes refreshing the page is a must. Kindly let me know if you need more details.
problem in refreshing the page after making two ajax calls
Thanks
No point in using AJAX if you are just going to refresh instantly after. Might as well just POST and let it do the refresh there. I realize this is what was said on the other thread but it's because it makes sense. For whatever reason though, if you still want to refresh, try using the jQuery AJAX call and in your success function just do window.location.reload(), that should work.
check out my answer
problem in refreshing the page after making two ajax calls

Resources