NNKL.COM
welcome to my space
X
Search:  
 HOME   ajax request problem
ajax request problem
Published by: mike 2010-03-18
Welcome to:nnkl.com

  • Problem using AJAX with IE7 beta - Rendering problem in Dropdown ::
    Dec 6, 2006 Problem using AJAX with IE7 beta - Rendering problem in Dropdown list items request.send(null);//Send the request with a null body.
    http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/497261bb-5f78-48ce-ac9e-2c957ae2081b
    HOME
    Hello Ext community,

    My problem:
    I have a tree.on('beforenodedrop',..... event (see below) and in this function i do a ajax request:
    The problem is that the variable check get the responseText after a short delay, but I need the response instantly. Is it possible to code a synchronous request or solve the problem in
    another way?
    tree.on('beforenodedrop', function(e){
    var s = e.data.selections, r = ;
    var z = e.target.attributes.id;

    for(var i = 0, len = s.length; i < len; i++){
    var User = s[i].data['sUsername']; // s[i] is a Record from the grid
    var UserID = s[i].data['nUseID'];
    var ProID = z;
    //var CheckUserProject = new Ext.data.Connection();

    if(FRight.form.isValid())
    {
    Ext.Ajax.request({
    url: 'test4.php',
    method: 'POST',
    async: true,
    params:
    {
    'nProID' : ProID,
    'nUseID' : UserID
    },
    });
    Ext.Ajax.on('requestcomplete', function(conn, response, object)
    {
    Rico Forum - Ajax/innerHTML problem in IE::
    21 posts - 6 authors - Last post: Jul 12, 2007I have a similar problem as this one. I have a div which should be filled with some data from the ajax request, but the inner html is never
    http://forum.openrico.org/topic/411
    HOME
    check = response.responseText;
    });
    // alert (check);
    if(check == 'ok' ){ // <-- filter duplicates
    r.push(new Ext.tree.TreeNode({ // build array of TreeNodes to add
    id: UserID,
    allowDrop:false,
    text: User
    }));
    }
    else
    {
    Ext.MessageBox.alert('Error', User+' already in project');
    }

    }
    else
    {
    e.cancel;
    Ext.MessageBox.alert('Error', 'You have to select a Right for '+User+'');
    }
    }
    e.dropNode = r // return the new nodes to the Tree DD
    e.cancel = r.length < 1; // cancel if all nodes were duplicates


    },{stopPropagation: true, preventDefault: true});


    so long cooky89


  • I don't think you're going about it the right way. Why are you making an Ajax request on each iteration of your loop?

    Can you explain what you're trying to do?


  • Thanks for your answer evant =)

    I have already tried that, it works perfect, but then i have another problem. I get no nodedrop and i can't find the reason :/

    tree.on('beforenodedrop', function(e){
    var s = e.data.selections, r = ;
    var z = e.target.attributes.id;

    for(var i = 0, len = s.length; i < len; i++){
    var User = s[i].data['sUsername']; // s[i] is a Record from the grid
    var UserID = s[i].data['nUseID'];
    var ProID = z;
    //var CheckUserProject = new Ext.data.Connection();

    if(FRight.form.isValid())
    {
    Ext.Ajax.request({
    url: 'test4.php',
    method: 'POST',
    async: true,
    params:
    {
    'nProID' : ProID,
    'nUseID' : UserID
    },
    success: function(response, options)
    {
    var check = response.responseText;
    if (check)
    {
    if(check == 'ok' ){ // <-- filter duplicates
    r.push(new Ext.tree.TreeNode({ // build array of TreeNodes to add
    id: UserID,
    allowDrop:false,
    text: User
    }));
    }
    else
    {
    Ext.MessageBox.alert('Error', User+' already in project');
    }


    }
    }
    });
    /* Ext.Ajax.on('requestcomplete', function(conn, response, object)
    {
    check = response.responseText;
    });*/
    // alert (check);
    }
    else
    {
    e.cancel;
    Ext.MessageBox.alert('Error', 'You have to select a Right for '+User+'');
    }
    }
    e.dropNode = r // return the new nodes to the Tree DD
    e.cancel = r.length < 1; // cancel if all nodes were duplicates



    }

    so long cooky89


  • Indeed :( (On a LAN I hope)


  • Hello again,

    ok i'll try to explain it:
    I will realise a grid to tree drag & drop (Users into projects). and everytime a grid row (user) is dropped on a treenode (project) a db connection should check if this user is already in the project. I will realise this db check with an ajax.request. I send the user id and the project id to test4.php and do there a sql query. if there are more results than 0 the ajax response is fail, else the response is ok

    I hope you know what i mean ^^

    thanks for your help
    cooky89


  • Ah I see,
    but i think there is no other possibility for me. I'll try it online and hope that the response time is not to long

    thanks a lot =)

    so long cooky


  • You can't have the request back instantaneously (would be nice though ;)).

    You need to use a callback method the request:


    Ext.Ajax.request(
    {
    url: 'test4.php',
    method: 'POST',
    params: { nProID : ProID, nUseID: UserID},
    scope: this,
    success: function(response, options)
    {
    var check = response.responseText;
    if (check)
    //do your processing here
    }
    }
    );


  • can you explain me what do you mean with..
    Does this plugin only works on lan?
    @cooky89 - Yes, localXHR will work just fine in either configuration. What Jeff and I are driving at is that - your users are in for potentially 'bumby ride' during the 'drop' phase.

    Every synchronous Ajax call you make blocks browser script execution until a response is received from the server (your group-membership validation) and the time it takes to get a response could be lengthy if it were not serviced by a server located on a local LAN segment.

    IOW: Using a synchronous call, Net latency + serverload will dictate what that final mouse drop looks like to a user. You should really try to avoid them if at all possible.


  • thanks para for your answer but thats not what i'm searching for.

    hendricd thank you very much, thats exactly what i'v searched =)

    so long cooky89
    Bummer for your users, cooky89.


  • Hello again :)

    can you explain me what do you mean with

    Bummer for your users, cooky89

    and

    Indeed (On a LAN I hope)

    Does this plugin only works on lan?

    so long cooky89


  • Although less secure, you may want to just preload the users into the nodes. This way all you have to do is say something like e.target.attributes.users.contains('e.dropNode.tex t');
    if you stored the users in a decent data structure.


  • If you feel you need synchronous AJAx support, try this. (http://extjs.com/forum/showthread.php?p=52350#post52350)
    Just add async:false to your Ajax request options.


  • thanks para for your answer but thats not what i'm searching for.

    hendricd thank you very much, thats exactly what i'v searched =)

    so long cooky89





  • Get Smart About Monitoring Virtual Machines
    Microsoft Gets Ex-Streamly Cozy with U.K.'s MediaWave

    You are looking at:nnkl.com's ajax request problem, click nnkl.com to home
  • follow mouse
  • multiple shapes in mask layer
  • building dynamic functionality into a address entry field zipcode finder
  • need desparate help somebody please
  • need a scrolling static text box
  • dcshoes com snow zoomable dragable images how
  • set height of rotated movie problem
  • simple uiscrollbar question
  • slide presentation need help and advise
  • question on simple custom scrollbar
  • graphic symbols increase publishing time
  • mask and distortion images
  • actionscript issues
  • xml photogallery help please
  •  
  • showing whats outside the stage
  • quick question about arrays
  • how to create a custom text scrollbar
  • preloading an external swf i just cant this
  • loading a movie clip
  • bitmapexporter desktop wallpaper size
  • flash 8 get a sound to play if it hasn t already started
  • need help with xml gallery
  • actionscript 3
  • general security open discussion
  • auto populating fields
  • how to add multiple containers
  • help i need to build an interactive map
  •  Homepage | Add to favorites | Contact us | Exchange links | LOGIN | Site map | 
    Copyright© 2008 nnkl.com        Site made:CFZ