Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: .ajax problem

  1. #1
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    .ajax problem

    Hi there,

    I am trying to use a .ajax method within a .ajaxFileUpload in the following way:

    Code:
    $('#buttonUpload').click(function (){
    
                   
    
         $.ajaxFileUpload({
    
     
    
             url:'doajaxfileupload_loadfile.php',
    
             secureuri:false,
    
             fileElementId:'fileToUpload',
    
             dataType: 'json',
    
             data:{error:'',msg:'',filetype:''},
    
    
    
             success: function (data, status){
    
    
    
                 if(typeof(data.error) != 'undefined'){
    
    
    
                     if(data.error !=''){ alert(data.error); }
    
                     else{ alert(data.msg); }
    
                 }
    
    
    
                 if(data.filetype=="Screenlog"){
    
    
    
                     document.getElementById('buttonUpload').style.color="green";
    
                     document.getElementById('issluploaded').value=data.filetype;
    
    
    
    	     }else if(data.filetype=="Plateconf"){
    
    
    
                     document.getElementById('buttonUpload').style.color="blue";
    
                     document.getElementById('isconfuploaded').value=data.filetype;
    
                 }
     
                 // load data from Plateconf.txt onto the screen
    
                 if(data.filetype=="Plateconf"){
    
                          
    
                     $.ajax({
    
    
    
                         url: 'PlateconfLoader.php',
    
                         dataType: 'json',
                            
    
                         success: function(moredata, status){
    
                             alert('Load was performed.');
    
                             alert(moredata['A01']);
    
    
                             for (var key in moredata){
    
    
    
                                 if (moredata.hasOwnProperty(key)){
    
    
    
                                     document.getElementById(key).className = moredata[key];
    
    		                 document.getElementById('hidden'+key).value = moredata[key];
                                 }
    
                             }
    
    	
    
                             alert('Load was performed.');
    
                         }
    
                     });
    
                 }
    
            },
    
    
    
            error: function (data, status, e){ alert(e); } 		   
    
       });
    
       		          
    
       return false;
    
    });
    The part inside the scope 'success: function(moredata, status)' doesn't seem to be working. I know that PlateconfLoader.php outputs some data, I see it on firebug. I am not sure what's wrong with the code.
    Last edited by alex.C; 12-09-2011 at 07:56 PM.

  • #2
    New to the CF scene
    Join Date
    Dec 2011
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is a shorter example:
    Code:
    $.getJSON('PlateconfLoader.php', function(data) {
    
             alert(data); //uncomment this for debug
             alert("here"); //uncomment this for debug
             for (var key in data){
    
    
    
                  if (data.hasOwnProperty(key)){
    
    
    
                       document.getElementById(key).className = data[key];
    
    		   document.getElementById('hidden'+key).value = data[key];
                                     
    
                  }
    
             }
    });
    Same problem, firebug tells me the output of PlateconfLoader.php but the alerts are not appearing.
    json data output from firebug:
    Sort by key
    A01 "sample"

    'Raw' Response:
    {'A01':'sample'}
    Last edited by alex.C; 12-09-2011 at 08:57 PM. Reason: adding more details


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •