$.ajax doesn't return the response, and can't because AJAX is
asyncronous. That's why you've got callbacks that execute once you've
got a response.
for what you're doing, just use:
$.post("/goods/detail/","id="+id, function(json){
//do something useful with the data
updateGoodsDetails(js
try to track down the json data,so you can:
1.alert(data); before return (if it doesn't work see the following)
2.change the POST method to GET from the server side and then input all
paras into browser and see what will you get.(if it doesn't work see the
following)
3.track down something from the
Because you're returning your data to $.ajax, which isn't expecting
anything to be returned from the callback.
Just use the success callback to do what you want with the result.
David
Adwin Wijaya wrote:
nope, i want to return as json.
price was there because i was logging into console. ju
nope, i want to return as json.
price was there because i was logging into console. just for
debugging :) and i will do the calculation after it return the value.
I tried using async:false
and the result still undefined
function getGoodsDetail(id){
$.ajax({
type: "POST",
u
But does it work with async set to false?
The code should work correctly if you have async set to false.
However, you cannot do this (return the JSON from the function)
properly without that setting set to false.
By the way, is it suppose to be:
result = price;
? I don't see what you're doing wit
hi Adwin,
it is "undefined" because it runs before ajax is finished.
maybe you should try to move "return result" next to the position of "result
= data"
let me know if it works
Charles
2009/3/5 Adwin Wijaya
>
> Hi,
>
> can i have callback function on the $.ajax ?
> I don't want to use async s
6 matches
Mail list logo