Jump to content
php.lv forumi
  • 0

JQuery globala mainiga iestatisana no funkcijas Bug


ziemelis

Question

Man ir forma ar funkciju e-pasta parbaudei (vai jau pastāv tāds)

Pievienoju vienkāršotu kodu

 

PROBLĒMA:

Kad posto datus un iegūst atbildi, valid jāiestata kā "false" - email nav pareizs.

1. iekš anonīmās funkcijas alerto: ka valid is false

2. pēc anonīmās funkcijas alerto: valid joprojām ir true!

 

Vajadzīgs lai pēc post alert rādītu ka valid ir false

Kur slēpjas kļūda?

 

 

//<input type="text" id="s_field" value=""/>
var valid = true;
var div = $("#s_field");
$.post("index.php",{id: 6}, function (data){

jQuery.data(div, "test", { first: 16});
valid = false;
alert('in post: '+jQuery.data(div, "test").first+'-'+valid);//should output: in post: 16-false
});
div = $("#s_field");
alert('after post: '+jQuery.data(div, "test").first+'-'+valid);//should output: after post: 16-false

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...