• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2462
  • Last Modified:

simple mootools AJAX call

using javascript with mootools,
I want a function that does a synchronous post ajax call with parameters,
and returns the resulting JSON

function simple_ajax(url, params) {
    // url is a standard url
    // params looks something like {'post_param1' : 'value1', 'post_param2' : 'value2'}

    ... what goes here? (probably uses toQueryString)...

    return eval(result)
}
0
xomn
Asked:
xomn
  • 2
1 Solution
 
hieloCommented:
new ajax(url,{postBody:params, onComplete: handlingFunction, update: 'targetDivId'}).request();
0
 
hieloCommented:
Better yet:
new ajax(url,{postBody:params, onComplete: function(request){processResult(request);}, update: 'targetDivId'}).request();
function processResult(requestObj)
{
      alert(result.responseText);
      //use this if you are returning JSON
      /*
      var data="";
      eval("data="+result.responseText+";");
      */
}
0
 
ahoffmannCommented:
>       eval("data="+result.responseText+";");
outch, hopefully there is no posibility for an attacker to manipulate this data ...

evil eval ...
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now