iis ajax json,PHP ajax json on iis

New to project and php..Environment IIS 7.5

Trying to get script to retrieve pw to work on IIS.

Link

submitAJAX

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('

} else {

$('#updateMsg').after('

}

}

/*

var tmpItem = replace($('#' + iErrorName + '_label').html(), ':', '');

tmpItem = Trim(tmpItem.replace(/]*>/gi, ''));

if (tmpItem != '') {

$('#updateMsgDescription').html($('#updateMsgDescription').html() + '
• ' + 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, '...', 'progress_dots.gif%5C'');

$('#' + tmpName + ' #updateMsg').html('' + iDisplay + '
');

}

/*

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('

Loading data...

');

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);

}

I am having issues with other functions using this. What happens when running it is Finding Password... is displayed but it sits there.

Thanks for taking a look,

Doug

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值