Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handler pending line 425 #27

Closed
arfa2 opened this issue Jun 4, 2015 · 10 comments
Closed

handler pending line 425 #27

arfa2 opened this issue Jun 4, 2015 · 10 comments
Labels

Comments

@arfa2
Copy link

arfa2 commented Jun 4, 2015

I wonder if there is still any life here? 2014 was the peak... :)

Anyhow, I am pressing on.
Simple login > 2 fields to check against a small database. Both fields have
data-validetta='remote[check_change]'
Basically it works BUT... once both fields are true - to get the onValid to fire - I need to force another error - then it fires.
event.preventDefault(); alert( event.isDefaultPrevented() ); // true
This has been a bit of a hair puller. What I am currently testing is remming line 425
this.handler = 'pending';
I am only an amateur but wonder why, at the end of all the remote testing, this is thrown in.
I get positives for line 368 & 412 -- ie. all is good and clear but then... we are back to pending.

I will test this with other forms but so far taking out that closing line seems to fix it.

Anyone????

@hsnaydd
Copy link
Owner

hsnaydd commented Jun 4, 2015

Hi @arfa2

Im alive :) but I had an operation acl surgery, so these days I could not take care of this plugin.

Btw validetta still developing on branch develop. v1.0.1 is ready but I could not complete documentation yet. That's why I dont publish.

As for the your problem, actually I dont fully understand. Can you explain a bit more?

@arfa2
Copy link
Author

arfa2 commented Jun 5, 2015

I am happy to hear from you. Great that you are alive. I hope all your medical things are settling OK. You don't look so old so hopefully the body behaves for a while on yet.

Problem - Forcing the error
With unRemmed line 425 in validetta.js... with both fields correct it would not fire on click submit. If I then went back into one of the fields and set it incorrectly to force an error - then reset that field correctly... it would work.

Solution? basically I rem #425 > this.handler = 'pending'; - and it works. Otherwise it does not. Please remember that I am not a pro. coder so I may be a bit slow or incorrect with some things. Working through the sequential logic of > remoteRequest : function {}... done - fail - always -- I wonder why, regardless of the state of the preceding 3 tests, this final line is there?
I am running jquery 1.8.2 + php5

Bottom line is - I have it working OK for my setup. I haven't tested it on-line.
I hope this is more clear for you.

I am an old PHP hack from way back and am enjoying working with your code. jquery is relatively new for me and trying to get validetta to do 'extra' things has given this old brain a comfortable challenge. I have other questions but will see if I can resolve on my own for now.

@arfa2
Copy link
Author

arfa2 commented Jun 8, 2015

I am working on a repeated-error example to post online but am quite busy just now. It also seems to have something to do with the form action=" " ...
I am trying both action = "#" and = "subScribe.php" -- I will post again in a while.

@hsnaydd
Copy link
Owner

hsnaydd commented Jun 8, 2015

It would be great to see an online example. Im waiting for your example.

@arfa2
Copy link
Author

arfa2 commented Jun 10, 2015

Excuse me if I am wasting time but there is different behaviour (for me) between offline & online. Clearly online is where the truth must exist and it seems that remming that line makes no visible difference. You can view my two examples -- identical except the 1 line remm'd. Part of the reason I have taken this long is due to some erratic, inconsistent behaviours (offline) and part of this is likely due to my ignorance of json
http://bodhinyanarama.net.nz/temp/valid/validAteRem.php
http://bodhinyanarama.net.nz/temp/valid/validNoRem/validAteNoRem.php

Two (I presume simple) questions:
1 - how to get the json data into the onValid function
2 - is it possible to manipulate the json data on submit - eg. get extra data from file based on user input.
I guess this creates a 3rd question: how to feed that new data back into onValid?

I will continue trying to reconcile offline differences and see if you have comments on this.
thx -

@arfa2
Copy link
Author

arfa2 commented Jun 10, 2015

Full form re-load then click submit (with no data, or just one line, entered) gives...
console error: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data - Line: 401 [ this is: result = JSON.parse( result ); ]
This only occurs offline - and only on the NoRem setup.

@arfa2 arfa2 closed this as completed Jun 11, 2015
@arfa2 arfa2 reopened this Jun 11, 2015
@arfa2
Copy link
Author

arfa2 commented Jun 11, 2015

ps: I have added
http://bodhinyanarama.net.nz/temp/valid/validAteRem.txt
http://bodhinyanarama.net.nz/temp/valid/validNoRem/validAteNoRem.txt
and same URL for /subScribeIN.txt if you want to view my code.

@hsnaydd
Copy link
Owner

hsnaydd commented Jun 11, 2015

Hi @arfa2

As I see it, you are on the wrong way. Firstly, Let me clarify that you should to use remote validation for validate a filed realtime. And If you read the the documentation for Remote Validation, The response from the ajax request must be a JSON formatted object, containing the properties "valid" and "message". You can not reach the value returned by using remote validation. Remote validation is only check a fileld is a valid or not.

Remote validation is asynchronous. Therefore we use this.handler = 'pending'. We have to prevent submit form before we receive the ajax response.

In this case, You should use this example

http://lab.hasanaydogdu.com/validetta/demo/ajax.html

Sory for the late reply.

Thanks.

@arfa2
Copy link
Author

arfa2 commented Jun 12, 2015

Your reply is most welcome.
I aplogise for my lack of js knowledge. ajax-json is new and there are basic concepts I have yet to learn. I will continue my study and see where it takes me. I have a working case with database checking and file saving > using a temp text file. It is clearly a workaround - but it does work.

BTW - I have reviewed several validation-script offerings and feel that yours is one of the best. Thank you. All I need to do is learn how to use it properly [grin]

I still need to reconcile my offline-online anomalies.

@hsnaydd
Copy link
Owner

hsnaydd commented Jun 12, 2015

Im glad you love it, My pleasure if I can help you.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants