davidrhoden / jquery-modalbox-plugin

Automatically exported from code.google.com/p/jquery-modalbox-plugin
0 stars 0 forks source link

errorMessageIfNoDataAvailable posted to server when using ajaxhref #9

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
<strong>No content available!</strong> is posted to the server when using ajax 
link.

        Example 3 / Ajax Link:
        ------------------------------------
        <a class="openmodalbox" href="javascript:void(0);">
            Demolink / Ajax Link
            <input type="hidden" name="ajaxhref" value="yourcustomtemplate.html" />
        </a>

When clicking the link, an ajax post is sent to the url yourcustomtemplate.html 
with a body content of "<strong>No content available!</strong>"

This is because data is null and the core method sets data to 
errorMessageIfNoDataAvailable when it is null.

On secure servers, this post triggers an exception because it contains at least 
a dangerous character (<)

Original issue reported on code.google.com by benjamin...@gmail.com on 16 Nov 2010 at 9:47

GoogleCodeExporter commented 9 years ago
Iam not sure that i understand your problem.

Example / Ajax Link:
<a class="openmodalbox" href="javascript:void(0);">
    Demolink
    <input type="hidden" name="ajaxhref" value="inc_ajaxinclude_1.php" />
</a>

Content of inc_ajaxinclude_1.php:
"if you see this, the ajax call is success"

It works fine. You can also view examples on "Ajax" in action on my demo page, 
including source code: http://opensource.steffenhollstein.de/templates/modalbox/

Best Regards,
Steffen

Original comment by steffen....@googlemail.com on 24 Nov 2010 at 7:49

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Important Note: the "inc_ajaxinclude_1.php" must not contain HTML structure 
like:

Wrong:
<html>
    <head></head>
    <body>
        if you see this, the ajax call is success
    </body>
</html>

Correct:
<div class="myCustomClass">if you see this, the ajax call is success<div>

Original comment by steffen....@googlemail.com on 24 Nov 2010 at 7:56

GoogleCodeExporter commented 9 years ago
Of course the result looks fine, well, under php servers which are unsecure :)
With ASP.NET there is a default setting preventing POST requests containing 
some characters like < or >. You can disable it per url.

Other than that, it works fine of course.

Original comment by benjamin...@gmail.com on 24 Nov 2010 at 7:58

GoogleCodeExporter commented 9 years ago
It works also on https. But i don't know your development environment. You can 
set the option "ajax_type" to change the type of request. Ddefault is "POST".

jQuery(document).ready(function(){
    jQuery(".openmodalbox").modalBox({
        ajax_type : 'GET'
    });
});

Let me know if you have any questions.

Original comment by steffen....@googlemail.com on 24 Nov 2010 at 8:11

GoogleCodeExporter commented 9 years ago
My comment has been deleted ??
If you use FIDDLER you will see that you are POSTing a content when making the 
ajax request:
===========
POST 
http://opensource.steffenhollstein.de/templates/modalbox/inc_ajaxinclude_1.php?a
jaxContent=true HTTP/1.1
Host: opensource.steffenhollstein.de
Connection: keep-alive
Referer: http://opensource.steffenhollstein.de/templates/modalbox/
Content-Length: 38
Origin: http://opensource.steffenhollstein.de
X-Requested-With: XMLHttpRequest
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Accept: */*
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.7 
(KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7
Accept-Encoding: gzip,deflate,sdch
Accept-Language: fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3

<strong>No content available!</strong>
==============

Original comment by benjamin...@gmail.com on 24 Nov 2010 at 8:11

GoogleCodeExporter commented 9 years ago
my server detects < and > in a POST request and by default stops the request 
(security feature).
It's not a problem for me. It's posting a content for nothing.

Original comment by benjamin...@gmail.com on 24 Nov 2010 at 8:13

GoogleCodeExporter commented 9 years ago
I use the Firefox AddOn "Tamper Data". Now i've understand what is the problem. 
The sended Post Parameter Name on ajax call is '<strong>No content 
available!</strong>'. Thank you for the hint! I will fix it as soon as possible.

Best Regards,
Steffen

Original comment by steffen....@googlemail.com on 24 Nov 2010 at 8:25

GoogleCodeExporter commented 9 years ago
Hi Benjamin,

please download the latest Revision 
(http://code.google.com/p/jquery-modalbox-plugin/downloads/detail?name=jquery.mo
dalbox-1.1.5.zip) and re-check my fix.

Thank You for testing!

Regards,
Steffen

Original comment by steffen....@googlemail.com on 28 Nov 2010 at 9:23

GoogleCodeExporter commented 9 years ago
Hi again Thalie for fixing.
I found a lot of errors in your code.
To see them go to Google closure compiler paste your script and go to the 
warnings tab.

I fixed them all in my version. And i added an "afterClose" delegate to 
settings so when close is called the delegate is called also.

I'll merge your version tomorrow.

Original comment by benja...@dealdeouf.com on 28 Nov 2010 at 10:14

GoogleCodeExporter commented 9 years ago
I am confused. The Google closure compiler say's "Compilation was a success!", 
No errors, no warnings:
http://closure-compiler.appspot.com/home

What errors you have found in my code?!

Original comment by steffen....@googlemail.com on 29 Nov 2010 at 1:08

GoogleCodeExporter commented 9 years ago
Clic "Advanced" in the compiler.

Warnings (in fact some are errors from my point of view):

JSC_WRONG_ARGUMENT_COUNT: Function parseInt: called with 1 argument(s). 
Function requires at least 2 argument(s) and no more than 2 argument(s). at 
line 89 character 60
obsoleteIE678Browser                : ((jQuery.browser.msie && parseInt(jQuery.browser.v...
                                                            ^
JSC_REDECLARED_VARIABLE: Redeclared variable: globaloptions at line 183 
character 4
var globaloptions = jQuery.extend({}, defaults, globaloptions);
    ^
JSC_WRONG_ARGUMENT_COUNT: Function jQuery.fn.modalBox.getlocales: called with 0 
argument(s). Function requires at least 1 argument(s) and no more than 1 
argument(s). at line 187 character 62
globaloptions.localizedStrings = jQuery.fn.modalBox.getlocales();
                                                              ^
JSC_WRONG_ARGUMENT_COUNT: Function jQuery.fn.modalBox.close: called with 0 
argument(s). Function requires at least 1 argument(s) and no more than 1 
argument(s). at line 235 character 24
jQuery.fn.modalBox.close();
                        ^
JSC_REDECLARED_VARIABLE: Redeclared variable: settings at line 246 character 4
var settings = jQuery.extend({// default settings
    ^
JSC_REDECLARED_VARIABLE: Redeclared variable: settings at line 336 character 4
var settings = jQuery.extend({// default settings
    ^
JSC_REDECLARED_VARIABLE: Redeclared variable: settings at line 369 character 4
var settings = jQuery.extend({// default settings
    ^
JSC_REDECLARED_VARIABLE: Redeclared variable: settings at line 426 character 4
var settings = jQuery.extend({// default settings
    ^
JSC_WRONG_ARGUMENT_COUNT: Function centerModalBox: called with 0 argument(s). 
Function requires at least 1 argument(s) and no more than 1 argument(s). at 
line 441 character 14
centerModalBox();
              ^
JSC_REDECLARED_VARIABLE: Redeclared variable: settings at line 457 character 4
var settings = jQuery.extend({// default settings
    ^
JSC_REDECLARED_VARIABLE: Redeclared variable: settings at line 487 character 4
var settings = jQuery.extend({
    ^
JSC_REDECLARED_VARIABLE: Redeclared variable: settings at line 559 character 4
var settings = jQuery.extend({
    ^
JSC_WRONG_ARGUMENT_COUNT: Function parseInt: called with 1 argument(s). 
Function requires at least 2 argument(s) and no more than 2 argument(s). at 
line 624 character 51
prepareCustomWidthOfModalBox += 'width:' + parseInt( globaloptions.setWidthOf...
                                                   ^
JSC_WRONG_ARGUMENT_COUNT: Function showFadingLayer: called with 0 argument(s). 
Function requires at least 1 argument(s) and no more than 1 argument(s). at 
line 631 character 15
showFadingLayer();
               ^
JSC_WRONG_ARGUMENT_COUNT: Function centerModalBox: called with 0 argument(s). 
Function requires at least 1 argument(s) and no more than 1 argument(s). at 
line 661 character 14
centerModalBox();
              ^
JSC_WRONG_ARGUMENT_COUNT: Function centerModalBox: called with 0 argument(s). 
Function requires at least 1 argument(s) and no more than 1 argument(s). at 
line 677 character 14
centerModalBox();
              ^
JSC_REDECLARED_VARIABLE: Redeclared variable: settings at line 706 character 4
var settings = jQuery.extend({
    ^
JSC_WRONG_ARGUMENT_COUNT: Function parseInt: called with 1 argument(s). 
Function requires at least 2 argument(s) and no more than 2 argument(s). at 
line 732 character 30
var setPositionLeft = parseInt( jQuery(window).width() - getModalboxContainer...
                              ^
JSC_WRONG_ARGUMENT_COUNT: Function parseInt: called with 1 argument(s). 
Function requires at least 2 argument(s) and no more than 2 argument(s). at 
line 749 character 25
setPositionTop = parseInt(
                         ^
JSC_WRONG_ARGUMENT_COUNT: Function parseInt: called with 1 argument(s). 
Function requires at least 2 argument(s) and no more than 2 argument(s). at 
line 753 character 29
if( setPositionTop > parseInt( globaloptions.positionTop ) ){
                             ^
JSC_WRONG_ARGUMENT_COUNT: Function parseInt: called with 1 argument(s). 
Function requires at least 2 argument(s) and no more than 2 argument(s). at 
line 761 character 25
setPositionTop = parseInt( jQuery(window).height() - getModalboxContainerHeig...
                         ^
JSC_WRONG_ARGUMENT_COUNT: Function simpleScrollTo: called with 0 argument(s). 
Function requires at least 1 argument(s) and no more than 1 argument(s). at 
line 821 character 14
simpleScrollTo();
              ^
JSC_WRONG_ARGUMENT_COUNT: Function centerModalBox: called with 0 argument(s). 
Function requires at least 1 argument(s) and no more than 1 argument(s). at 
line 838 character 14
centerModalBox();
              ^
JSC_REDECLARED_VARIABLE: Redeclared variable: settings at line 867 character 4
var settings = jQuery.extend({//defaults
    ^
JSC_WRONG_ARGUMENT_COUNT: Function jQuery.fn.modalBox.close: called with 0 
argument(s). Function requires at least 1 argument(s) and no more than 1 
argument(s). at line 897 character 24
jQuery.fn.modalBox.close();
                        ^
JSC_WRONG_ARGUMENT_COUNT: Function showFadingLayer: called with 0 argument(s). 
Function requires at least 1 argument(s) and no more than 1 argument(s). at 
line 903 character 15
showFadingLayer();
               ^
JSC_REDECLARED_VARIABLE: Redeclared variable: settings at line 931 character 4
var settings = jQuery.extend({
    ^
JSC_WRONG_ARGUMENT_COUNT: Function jQuery.fn.modalBox.getlocales: called with 0 
argument(s). Function requires at least 1 argument(s) and no more than 1 
argument(s). at line 941 character 57
settings.localizedStrings = jQuery.fn.modalBox.getlocales();
                                                         ^
JSC_REDECLARED_VARIABLE: Redeclared variable: settings at line 986 character 4
var settings = jQuery.extend({}, defaults, settings);
    ^
JSC_REDECLARED_VARIABLE: Redeclared variable: settings at line 1021 character 4
var settings = jQuery.extend({
    ^
JSC_REDECLARED_VARIABLE: Redeclared variable: settings at line 1037 character 4
var settings = jQuery.extend({
    ^
JSC_REDECLARED_VARIABLE: Redeclared variable: settings at line 1056 character 4
var settings = jQuery.extend({}, defaults, settings);
    ^
JSC_REDECLARED_VARIABLE: Redeclared variable: settings at line 1082 character 4
var settings = jQuery.extend({}, defaults, settings);
    ^
JSC_WRONG_ARGUMENT_COUNT: Function modalboxBuilder: called with 0 argument(s). 
Function requires at least 1 argument(s) and no more than 1 argument(s). at 
line 1091 character 45
var createModalboxContainer = modalboxBuilder();
                                             ^
JSC_WRONG_ARGUMENT_COUNT: Function jQuery.fn.modalBox.precache: called with 0 
argument(s). Function requires at least 1 argument(s) and no more than 1 
argument(s). at line 1109 character 27
jQuery.fn.modalBox.precache();

Original comment by benjamin...@gmail.com on 29 Nov 2010 at 3:57

GoogleCodeExporter commented 9 years ago
There is also a type error, somewhere there is "setting" instead of "settings"

Original comment by benjamin...@gmail.com on 29 Nov 2010 at 3:58

GoogleCodeExporter commented 9 years ago
And i really need the afterClose delegate :)

(you have already one delegate called "callFunctionAfterSuccess" which name is 
not understandable. After success of what ?)

Original comment by benjamin...@gmail.com on 29 Nov 2010 at 4:00

GoogleCodeExporter commented 9 years ago
And from inside you class declaration, you still use jQuery instead of $
This is not required as you start the declaration with (function($){
It is cleaner to use $.

Original comment by benjamin...@gmail.com on 29 Nov 2010 at 4:03

GoogleCodeExporter commented 9 years ago
Whatever you did with my code. The original has NO Errors. And for me is the 
declaration "jQuery" more clearly :o)

Regards,
Steffen

Original comment by steffen....@googlemail.com on 29 Nov 2010 at 4:16

GoogleCodeExporter commented 9 years ago
In the next version i will add a "after close" call back function. This is a 
god hint. By the way, "callFunctionAfterSuccess" is available for checking in 
the doc (http://code.google.com/p/jquery-modalbox-plugin/).

Regards,
Steffen

Original comment by steffen....@googlemail.com on 29 Nov 2010 at 4:26

GoogleCodeExporter commented 9 years ago
Well you are declaring variables that are function parameters. I never saw that 
anywhere else :)

function(settings)
{
var settings = ...;

!!

This is the main point.

And if you prefer to use jQuery instead of $, then you should pass jQuery as 
the variable instead of $ in the "main" outside function.

callFunctionAfterSuccess: by its name, we don't know if it is called after the 
dialog appears, before it appears,  before it disappear, after, or all of those.

Have a look at the modal dialog used by GitHub (jquery facebox). The good 
things with it are the number of events it provides. The bad thing is first 
they are events instead of delegates, and second that all settings are global 
and can not be modified later.

Original comment by benjamin...@gmail.com on 29 Nov 2010 at 7:13

GoogleCodeExporter commented 9 years ago
Well, you can still learn a lot about programming jQuery PlugIns:
http://docs.jquery.com/Plugins/Authoring

"For more complex and customizable plugins that provide many options, it's a 
best practice to have default settings that can get extended (using $.extend) 
when the plugin is invoked. So instead of calling a plugin with a large number 
of arguments, you can call it with one argument which is an object literal of 
the settings you would like to override. Here's how you do it."

:o)

Original comment by steffen....@googlemail.com on 29 Nov 2010 at 7:49

GoogleCodeExporter commented 9 years ago
And I also incidentally. I learn every day. That is the reason why I pursue 
this project.

Original comment by steffen....@googlemail.com on 29 Nov 2010 at 7:54

GoogleCodeExporter commented 9 years ago
Hi again, you didn't understood correctly. The settings system is perfect. I 
was telling about (function($){ if you don't use $ inside the plugin but use 
jQuery instead then you should use (function(jQuery){ not (function($){. Also 
you should simply not declare a variable again, that is what the google closure 
compiler tells you. Alternatively you can use JSLint to verify that your script 
don't violate best practices and don't have common errors.

Original comment by benjamin...@gmail.com on 29 Nov 2010 at 9:06

GoogleCodeExporter commented 9 years ago
Sry, my english is realy bad. I've added a new Revision of my Plugin (1.1.7). 
There is a after close callback functionality.

Regards,
Steffen

Original comment by steffen....@googlemail.com on 29 Nov 2010 at 10:09

GoogleCodeExporter commented 9 years ago
nice shot thks :)

Original comment by benjamin...@gmail.com on 29 Nov 2010 at 10:14