Safari calls my controller twice when loading the JSP - model-view-controller

Doesn't happen in Firefox. I deactivated the extensions. didnt help. Version is 5.0.1.
Any ideas?

Leppie (above) was right...for me at least. I had a <img src=""/> in my JSP that caused Safari to load the page twice...which in turned called saveToken twice in my Struts Action and subsequently caused isTokenValid to return false when it shouldn't have.
The simple solution is to fix the IMG element by referencing an image in the src tag.
Enjoy,
Randy

Related

Issue regarding Ajax in Grails

I am new to Grails. I tried several sites such as this one to practice grails-view/ajax. But g:remoteLink is not working properly. When I click on the g:remoteLink on the .gsp page it render the new page instead of updating a selective portion of the current page.
Can anybody give me any solution?
Thanks in advance.
JDK version : 1.7 update 45
Grails version : 2.2.0
#ManazirAhsan
When you used g:remoteLink its working as a method/function calling in a controller. So in the corresponding controller if you add a page to view then it will do accordingly.
So you can solve your issue by rendering template to a view page using "div" to update corresnponding portion.
you can you use render instead of g:remoteLink or render in the action g:remoteLink is passing.
Hope this will work. Or you can comment any more issue. :)

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

iframe with # in the src attribute not loading in Firefox

The below iframe will display in every browser except Firefox. Any insight as to why?
<iframe src="http://sitename.com/directory/#pagename/"></iframe>
The issue was with firefox doing either some url decoding or looking at window.location.hash rather than window.location.href. The hash in the url was stubbing part of url needed to load the iframe properly.
Changing the src attribute to http://sitename.com/directory#pagename/ solved the problem.

Grails and AJAX: remoteLink causes redirect, not updated div

I'm trying to make an ajax enabled webapp using the tag. For some reason,
it redirects the entire page to my template, and doesn't update the specified div.
Here is what I have so far:
In the head of my GSP file:
<g:javascript library="jquery" />
<g:setProvider library="jquery"/>
In the body of my GSP file:
<div id="message"></div>
<g:remoteLink controller ="reqOff" action="quick_req" update="[success: 'message']">ar</g:remoteLink>
My controller method returns a template; which seems to be working fine.
The problem:
Right now, rather than update the div, it renders my template on a new page.
Other Notes:
- My grails version is 1.4.0.M1
- My jquery plugin is installed and updated to 1.7.2
- I have no other conflicting JS libraries in my view
I fixed the problem with JQuery and incidentally it was related to the CSS problem mentioned in the comments. As it turns out Gregg was on to something when he pointed out that the jQuery may not be loading in.
What I did is upgrade my resources plugin, and since it brokeing my app, forced me to learn what the resources plugin actually does. After setting up my modules and getting the r:require and r:layoutResources tag in, everything loads in just fine. It took a little trial and error, and I followed a tutorial type blog post from the plugin's author: http://www.anyware.co.uk/2005/2011/09/12/optimising-your-application-with-grails-resources-plugin/
In conclusion, check to make sure your resources are loading correctly with the resources plugin. I was under the assumption that the g:javascript tag loaded jQuery, but for my app, this apparently was not the case.

Why isn't Firefox submitting my form twice?

HTML/JS Here: http://pastebin.com/JrtfeAtw
PHP Here: http://pastebin.com/EcRHCwmY
Based on Ajax F1's tutorial here: www.ajaxf1.com/tutorial/ajax-file-upload-tutorial.html
Anyway, my problem. In Chrome, this works fine. However, in Firefox, it will upload the first file no problem, and begin uploading the second one. I've traced it in Firebug and it definitely calls form.submit() on the correct form, and the form has the correct fields in it, but for some reason my form never gets submitted.
Is this because I'm submitting the same form twice? And if so, is there a workaround that anyone knows of?
Cheers!
I have no explanation for this, however, setting the source of the iFrame to about:blank between each image upload fixed the issue.

Resources