Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-09-2011, 06:54 PM   PM User | #1
alex.C
New to the CF scene

 
Join Date: Dec 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
alex.C is an unknown quantity at this point
.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 06:56 PM..
alex.C is offline   Reply With Quote
Old 12-09-2011, 07:55 PM   PM User | #2
alex.C
New to the CF scene

 
Join Date: Dec 2011
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
alex.C is an unknown quantity at this point
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 07:57 PM.. Reason: adding more details
alex.C is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:27 AM.


Advertisement
Log in to turn off these ads.