---
title: "set value out of mootools request"  
description: "set value out of mootools request"  
author: "Anonymous User"  
published: 2013-06-20  
updated: 2013-06-20  
canonical: https://www.mindstick.com/forum/1238/set-value-out-of-mootools-request  
category: "json"  
tags: ["json"]  
reading_time: 1 minute  

---

# set value out of mootools request

Hi Expert,\
\
I want to perform a [AJAX request](https://www.mindstick.com/forum/157891/what-is-the-role-of-the-jsonresult-class-in-mvc-how-can-it-use-to-return-data-to-an-ajax-request) in a [function](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) and then [return the result](https://www.mindstick.com/forum/159730/how-can-i-return-the-result-from-the-ajax-call) of the request (using mootools). The request and the [response](https://www.mindstick.com/forum/12719/how-to-make-response-write-display-special-character-like-lt-gt) are working like I want, but the [variable](https://www.mindstick.com/articles/1807/objective-c-data-types-variables-object-creation) is still 0.\
\
here my function:\
\
function recalcPrice(baseprice, rclass, count){\
var newPrice = 0;\
var request = new Request.JSON({\
method: 'post',\
url: '[controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc)/xhr_request.php',\
async: false, //UPDATE: that line [solves the problem](https://answers.mindstick.com/qa/94367/is-there-any-app-that-automatically-solves-the-problem-of-unfortunately-system-has-stopped-working-in-an-android-phone)\
data: {\
'performaction' : 'calcNumberPrice',\
'baseprice' : baseprice,\
'class' : class,\
'number' : count\
},\
timeout : 5000,\
onComplete: function(response) {\
console.log('response=' + response);\
if(response.status == '[success](https://www.mindstick.com/articles/12957/best-tips-to-make-your-ghostwriting-experience-a-success)'){\
console.log('price = ' + response.price);\
newPrice = response.price;\
}\
}\
});\
request.send();\
return newPrice;\
}\
\
console shows that the price has [calculated](https://answers.mindstick.com/qa/31699/what-is-sensex-and-how-it-is-calculated) correctly, but the variable newPrice is not changed...\
\
The problem is allready known in SO but shouldn't this solution made it?\
\
Any help on above is really appreciated.\

## Replies

### Reply by Sumit Kesarwani

Hi,\
set asynchronous request to false as following\
async: false,\
I hope now it's working.\


---

Original Source: https://www.mindstick.com/forum/1238/set-value-out-of-mootools-request

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
