English 中文(简体)
我怎么能够从吉克丽的贾克斯请求中获取数据?
原标题:How can I get returning data from jquery ajax request?
function isNewUsername(str){
    var result;
    $.post( /api/isnewusername , 
            {username:str},
            function(data) {
                result = data.result;
            }, 
            "json");
    return result;
}

So , my problem is very simple but I can not figure it out . I want to access result from the isnewusername function . I am very curious about answer because I spent 1 hour on it . Thank you

最佳回答

http://api.jquery.com/jQuery.post/“rel=“nofollow noreferer” 职衔: 页: 1 彩票功能意味着你正在做不寻常的电话。 因此,只有作出成功的反应,才能把你的职责称为“贵”组织,并将其成果放在“<数据>/代码”栏目中。

说明:

function isNewUsername(str){
    $.post( /api/isnewusername , 
            {username:str},
            function(data) {
                alert(data.result);
            }, 
            "json");
}

她说,你可以修改你的代码,具体指明a 同步电话,但有可能将用户捆绑起来,直到请求被退回。

问题回答

不能再做,因为麻风病的问询是不合时宜的(即,它们不会 block,结果不会立即出现,而是当服务器实际反应时。 你不得不把另一个职能称为成果(否则,只有在实际获得成果时,才会有结果)。

例如:

function isNewUsername(str){
    $.post( /api/isnewusername , 
            {username:str},
            function(data) {
                someOtherFunction(data.result);
            }, 
            "json");
}




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签