English 中文(简体)
Javascrap/j 查询未定义
原标题:Javascript/jQuery undefined

标题被命名为“ jQuery / Javascript ” 的原因不是因为我假设jQuery 是语言, 我知道jQuery 是一本有javascript 语言的图书馆, 只是以防某些pedantic 读者读到这个。 我写这个标题的原因是, 我不知道代码、 jQuery 或 Javascript (所有jQuery 编译的代码)有什么问题 。

好吧,回到问题,看看下面的代码, 他们给了我一个不确定的价值

//username validation
function username_val(){
    username_value = $("input[name= username ]").val();
    span_error = "span[name= username_error ]";
    $(span_error).load( ajax_signup_username , {php_username_error:username_value},  function(){
        return true;
    });
}

我提醒了大家,然后“未定义”又被退回。我假设将归还一个真实的真相。

function final_val(){
        alert( username_val() );
}

EDIT: : 你们中有些人说,我只能在成功参数上恢复真实性, 但我需要这个来验证, 所以如果所有验证方法都是真的, 在最后_ val会恢复真实性。 要点是, 我需要在最后_ val () 或者你们有其他方法来验证它, 请告诉我。 注意: 我赶时间, 所以如果我误解您的回答, 请原谅我。 我会离开几个小时, 直到我检查你们的答复 。

谢谢!

最佳回答

您需要将 alert( username_ val ()); 设定为成功功能中的 < code> (username_ val ()); 。 由于 < code>.load () 是非同步的方法, 所以在立即呼叫后它不能 < code> return true true 。 因此您可以尝试 :

 $(span_error).load( ajax_signup_username , {php_username_error:username_value},  function(){
     alert( Something );
     var response = true;
     final_val(response);
 });

 function final_val(response){
     alert( response);
 }

"http://api.jquery.com/load/"rel="no follow" >这里 是 doco

问题回答

暂无回答




相关问题
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.

热门标签