• Hi guys,

    I have the following jquery code:

    $(document).ready(function() {
    
    	// Load full report on page load
    	loadAjaxReport(0, '1999-01-01', GetCurrentDate());
    
    	$('#from_date').Zebra_DatePicker();
    	$('#to_date').Zebra_DatePicker();	
    
    	$("a.btnreport").click( function(ev) {
    		ev.preventDefault();
    
    		var customer_id = $('#customerid').val();
    		var from_date = $('#from_date').val();
    		var to_date = $('#to_date').val();
    
    		loadAjaxReport(customer_id, from_date, to_date);
    
       	}); 
    
    	$("#loading").ajaxStart(function(){
    	    $(this).show();
    	 }).ajaxStop(function(){
    	    $(this).hide();
    	 });
    
    });
    
    function loadAjaxReport(customer_id, from_date, to_date){
    	clients = new Array();
    	 jQuery.ajax({
    		 	type: "POST",
    			url: report_ajax_script.ajaxurl,
    			dataType: 'html',
    			cache: false,
    			data: ({action: 'loadCustomerReport', id: customer_id, from: from_date, to: to_date}),
    			success: function(data) {
    				$("#customer_list").html(data);
    			},
    
    		});
    }
    
    //get current date
    
    function GetCurrentDate(){
    
    	var d = new Date();
    
    	var month = d.getMonth()+1;
    	var day = d.getDate();
    
    	var output = d.getFullYear() + '/' +
    	    ((''+month).length<2 ? '0' : '') + month + '/' +
    	    ((''+day).length<2 ? '0' : '') + day;
    
    	return output;
    
    }

    Basically it reads the date from the zebra date picker and calls an Ajax script that does the math and returns a custom report. It works fine, however it crashes the default WordPress image upload. Whenever I attempt to upload an image, I get a HTML image upload which opens in a different window and will not upload any images – the lightbox image upload effect is broken and the jquery is as good as a dead horse.

    However the moment I comment out the following part, everything works again (obviously now not for the custom ajax report).
    //loadAjaxReport(0, '1999-01-01', GetCurrentDate());
    ===> the above commented out enables the image upload to work

    1. Script get today’s date and runs a query from date 01/01/199
    2. Date pickers allow me to custom run the query to obtain custom results

    What breaks the image upload is the:
    `loadAjaxReport(0, ‘1999-01-01′, GetCurrentDate());’

    What in the jquery could possibly be breaking the code?

  • The topic ‘Image Upload and Custom Ajax’ is closed to new replies.