PhpxJson = function() { var buttonName = null; function Initialize() { RegisterScripts(); SubscribeOnLoad(); } function RegisterScripts() { } function SubscribeOnLoad() { if ( window.addEventListener ) { window.addEventListener( 'load', onLoad, false ); } else if ( window.attachEvent ) { window.attachEvent( 'onload', onLoad ); } else { window.onload = onLoad; } } function Bind() { jQuery('#ncClient form').bind('submit', function(e) { e.preventDefault(); Unbind(); Submit( this ); }); jQuery('#ncClient input[type=\'submit\']').bind('click', function() { buttonName = this.name; }); /* jQuery('#ncClient a').bind('click', function(e) { e.preventDefault(); Unbind(); GetJson( this.href+'?callback=?' ); }); */ } function Unbind() { NextCarDestroy(); /* jQuery('#ncClient a').unbind('click'); */ jQuery('#ncClient input[type=\'submit\']').unbind('click'); jQuery('#ncClient').unbind('submit'); } function Submit( form ) { var path = 'http://nextcar.ru/client/usedtdvsales/?callback=?'; if (form!=null) { path += '&'+jQuery(form).serialize(); } if (buttonName!=null && buttonName.length>0) { path += '&' + buttonName + '='; } GetJson( path ); } function GetJson( url ) { jQuery.blockUI( { css: { border: 'solid 5px #999', padding: '30px', backgroundColor: '#FFF', '-webkit-border-radius': '20px', '-moz-border-radius': '20px', opacity: .5, color: '#000' }, message: '' }); jQuery.getJSON( url, onSubmitFinished ); buttonName = null; } function onLoad() { Submit(); } function onSubmitFinished(data, textStatus) { jQuery.unblockUI(); // textStatus will be one of the following values: // timeout,error,notmodified,success,parsererror switch(textStatus) { case 'timeout': case 'error': case 'parsererror': alert(textStatus); return; }; jQuery('#ncClient').html(data); NextCarInitialize(); Bind(); } Initialize(); } var PhpxJsonInstance = new PhpxJson();