SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Zealot fatnic's Avatar
    Join Date
    Aug 2006
    Location
    Lincoln, UK
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    strange prototype problem

    Hi. I'm using prototype to do some ajax requests and using this function to pass the value of a slider
    Code:
    function setPeriod(v) {
    	alert(v);
    	new Ajax.Request('inc/updateperiod.app.php',
      {
        method:'get',
    	parameters: {period: v},
        onSuccess: function(v){
          alert("Period set to "+v+" (days)");
        },
        onFailure: function(){ alert("Unable to update \'config.ini\'") }
      });
    }
    If I run
    Code:
    setPeriod(14)
    the first alert shows (correctly) 14, however the second shows
    Code:
    Period set to [object Object] (days)
    Am I overlooking something really simple?

  2. #2
    SitePoint Zealot fatnic's Avatar
    Join Date
    Aug 2006
    Location
    Lincoln, UK
    Posts
    191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK. Worked it out. My own fault for using 'v' thorughout!

    The 'v' in function(v) is not passing 'v' to the function, but the return of the successful AJAX request. D'Oh. Got it now!


Bookmarks

Posting Permissions

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