Advertisement
Advertisement
| 04.22.2008 at 01:57AM PDT, ID: 23342185 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: |
Part 1 of the script not posted here simply contains the vars.
Part 2 of the script not posted here simply loops through the html form and sets up the event listeners eg:
$(elementList[n].id).observe('blur', respondToBlur); //triggers the validation request.
respondToBlur calls:
goValidate(element); //do the ajax request
Part 3 of the script is my ajax request:
function goValidate(element) {
// 1. prepare the ajax Request
var actionURL = action; // the php validation script
//var actionURL = action + '?id=' + element.id + '&value=' + $F(element);
// 2. now do the ajax Request
new Ajax.Request(
actionURL, //url
{
//method:method,
parameters:Form.serialize(formID), // this takes all the POST fields and sends them to the controller.php
asynchronous:true,
requestHeaders: ['Cache-Control', 'no-cache', 'Pragma', 'no-cache'],
onComplete: function(request) {
// check the incoming literal string format eg pass|Good message or fail|Sorry bad message and update accordingly
var fullMessage = request.responseText;
var myArray = fullMessage.split('|'); //split items at comma to array
var successCode = myArray[0]; // fail or pass
var messageText = myArray[1]; // eg good message
if (successCode == 'pass') {
// 1. successful validation, now UPDATE THE MESSAGE FIELD
if (messageText) {
$(updateElem).innerHTML = messageText; // add message to message div
}
} else if (successCode == 'fail') { // PHP validation failed
// 1. validation failed so update the message field
if (messageText) {
$(updateElem).innerHTML = messageText; // add message to message div
}
} else {
//system failure!
alert("Ooops, something went wrong with the PHP response as no error code was found - probably a config or server error so better log something! " + fullMessage);
}
}
});
//only do this validating part when the first stage of the ajax request has been sent.
}//ends function goValidate
|