新项目和 php..Environment IIS 7.5
试图让脚本检索 pw 以在 IIS 上工作。
关联
提交AJAX
function submitAJAX(iPage, iData, iSync) {
if (iSync == null) {
iSync = true;
}
$.ajax({
type: "POST",
dataType: "json",
url: iPage,
global: true,
async: iSync,
data: iData,
success: function(data, textStatus) {
handleAJAXResponse(data, textStatus);
}
});
}
ajax.js
var templateForm;
var desinationForm;
var containerForm;
/*
Wrapper for the JQuery AJAX .post function
*/
function submitAJAX(iPage, iData, iSync) {
if (iSync == null) {
iSync = true;
}
$.ajax({
type: "POST",
dataType: "json",
url: iPage,
global: true,
async: iSync,
data: iData,
success: function(data, textStatus) {
handleAJAXResponse(data, textStatus);
}
});
}
/*
Handle the JQuery AJAX Post response
*/
function handleAJAXResponse(jsonObj, textStatus) {
// Update the destination form
if ((templateForm) && (desinationForm)) {
desinationForm.html(templateForm.html());
containerForm = desinationForm.attr('id');
}
templateForm = '';
desinationForm = '';
if (textStatus == 'success') {
processJSONData(jsonObj, containerForm);
} else {
alert('AJAX Execution Error: ' + textStatus);
}
}
/*
Process the specified JSON data object
*/
function processJSONData(iJSON, iContainer) {
$.each(iJSON, function(iVariable, iValue) {
if (iValue) {
if (iContainer) {
var tmpObj = $('#' + iContainer + ' #' + iVariable);
//if (!tmpObj.size()) { var tmpObj = $('#' + iContainer + " [name=" + iVariable + "]"); }
//if (!tmpObj.size()) { var tmpObj = $('#' + iContainer + " [id*=" + iVariable + "]"); }
//if (!tmpObj.size()) { var tmpObj = $('#' + iContainer + " [name*=" + iVariable + "]"); }
} else {
var tmpObj = $('#' + iVariable);
//if (!tmpObj.size()) { var tmpObj = $("[name=" + iVariable + "]"); }
//if (!tmpObj.size()) { var tmpObj = $("[id*=" + iVariable + "]"); }
//if (!tmpObj.size()) { var tmpObj = $("[name*=" + iVariable + "]"); }
}
// If the current object is another JSON oject
if ((typeof iValue == 'object') && (iValue.toString().indexOf('object') > -1)) {
if (iContainer) {
processJSONData(iValue, iContainer + ' #' + iVariable);
} else {
processJSONData(iValue, iVariable);
}
} else {
//alert(iContainer + '.' + iVariable + ' = ' + iValue + ' : ' + tmpObj.size());
// Object exists on the page
if (tmpObj.size()) {
setFieldValue(tmpObj, iValue);
// Object doesn't exist on the page
} else {
// Check for a JS function
if (iVariable.indexOf('script_') == 0) {
setTimeout(iValue, 10);
//eval(iValue);
// Check for a form validation error
} else if (iVariable.indexOf('_error') > -1) {
setFormError(iVariable.replace('_error', ''));
} else {
//alert('AJAX Variable Error: ' + iVariable);
}
}
}
}
});
}
function setFieldValue(iFieldObj, iValue) {
switch (iFieldObj.attr('type')) {
case 'text':
case 'password':
case 'file':
case 'hidden':
case 'submit':
case 'button':
case 'reset':
case 'textarea':
case 'select-multiple':
iFieldObj.val(iValue);
//alert($(tmpObj).fieldValue());
break;
case 'checkbox':
if (!iFieldObj.attr('checked')) {
iFieldObj.trigger('click');
} else {
//iFieldObj.attr('checked', false);
}
break;
case 'select-one':
iFieldObj.val(iValue);
break;
case 'radio':
$("input[name=" + iFieldObj.attr('id') + "]").each(function() {
if ($(this).val() == iValue) {
$(this).attr('checked', 'checked');
}
});
break;
default:
if ((document.getElementById(iFieldObj.attr('id')).type == 'select-one') || (document.getElementById(iFieldObj.attr('id')).type == 'select-multiple')) {
iFieldObj.val(iValue);
} else if (iFieldObj.attr('id')) {
iFieldObj.html(iValue);
}
break;
}
}
/*
Add the error classes to the specified field
*/
function setFormError(iErrorName) {
if (iErrorName.indexOf(']') > 0) {
var tmpData = iErrorName.split('[');
var tmpIndex = 0;
for (i = 1; i < tmpData.length; i ++) {
tmpData[i] = tmpData[i].replace(']', '');
//if ((tmpData[i] * 1) == 0) { tmpData[i] = 1; }
tmpIndex = tmpIndex + (tmpData[i] * 1);
}
//alert(tmpData[0] + '\n' + tmpIndex);
$('[id*=' + tmpData[0] + ']:input').eq(tmpIndex).addClass('errorElem');
$('[id*=' + tmpData[0] + '_label]').eq(tmpIndex).addClass('errorCell');
} else {
$('#' + iErrorName).addClass('errorElem');
//$("[name=" + iErrorName + "]").addClass('errorElem');
$('#' + iErrorName + '_label').addClass('errorCell');
}
if ($('#updateMsgDescription').size() == 0) {
if (containerForm) {
$('#' + containerForm + ' #updateMsg').after('<div id="updateMsgDescription"></div>');
} else {
$('#updateMsg').after('<div id="updateMsgDescription"></div>');
}
}
/*
var tmpItem = replace($('#' + iErrorName + '_label').html(), ':', '');
tmpItem = Trim(tmpItem.replace(/<\/?(?!\!)[^>]*>/gi, ''));
if (tmpItem != '') {
$('#updateMsgDescription').html($('#updateMsgDescription').html() + '<br>• ' + tmpItem);
}
*/
}
/*
Clean all error elements in the specified form
*/
function clearFormErrors(iFormObj) {
$('.errorElem').removeClass('errorElem');
$('.errorCell').removeClass('errorCell');
}
/*
The error element has been focused so clear any error objects
*/
function cleanFormError(iErrorObj) {
/*
var tmpName = iErrorObj.id || iErrorObj.name || iErrorObj.attr('id') || iErrorObj.attr('name');
if (tmpName) {
$('#' + tmpName).removeClass('errorElem');
//$("[name=" + tmpName + "]").removeClass('errorElem');
$('#' + tmpName + '_label').removeClass('errorCell');
}
*/
$(iErrorObj).removeClass('errorElem');
$(iErrorObj).parent().parent().find('#' + $(iErrorObj).attr('id') + '_label').removeClass('errorCell');
}
/*
Disable a form button, and set updating display label
*/
function doFormSubmit(iDisplay, iForm, iDisabledBtn) {
if (iDisabledBtn == null) {
iDisabledBtn = true;
}
var tmpName = iForm.name || iForm.id || iForm.attr('id');
containerForm = tmpName;
// Clear all form errors
clearFormErrors(iForm);
var tmpType = $(iForm).attr("enctype");
if (tmpType == 'multipart/form-data') {
//alert('file upload');
} else {
if (iDisabledBtn) {
$('#' + tmpName + ' #updateBtn').attr('disabled', true);
}
}
$('#updateMsgDescription').remove();
//$('#' + tmpName + ' #updateBtn').attr('disabled', true);
iDisplay = replace(iDisplay, '...', '<img src=\'images/progress_dots.gif\'>');
$('#' + tmpName + ' #updateMsg').html('<span class="btext12">' + iDisplay + '</span><br><br>');
}
/*
Show a data form for the specified form
*/
function showDataForm(iID, iFormName, iFileName) {
var Now = new Date();
var Start = Now.getTime()
// Remove all existing update forms
//$('[id*=update_]').html('');
//$('[id*=image_]').attr('src', '/images/plus_box.gif');
toggleLinks('update_' + iID, 'image_' + iID);
if (($('#image_' + iID).attr('src')).indexOf('minus') == -1) {
return false;
}
$('#update_' + iID).html('<br><center><b>Loading data...</b></center><br>');
var tmpAddress = window.location.href;
if (tmpAddress.indexOf('?') > 0) {
var tmpDat = tmpAddress.split('?');
tmpAddress = tmpDat[0];
}
templateForm = $('#' + iFormName);
desinationForm = $('#update_' + iID);
if (iFileName == null) {
submitAJAX(tmpAddress + 'add_new.php?action=XML_GET', 1);
//alert(tmpAddress + 'add_new.php?action=XML_GET', { 0: iID });
} else {
submitAJAX(iFileName, {0: iID});
}
var Now = new Date();
//alert((Now.getTime() - Start));
//setTimeout('alert($(\'#update_1 #user_id\').fieldValue());', 2000);
}
我在使用其他功能时遇到问题。运行它时会发生什么是正在查找密码... 显示但它坐在那里。
谢谢你看,道格