View Full Version : vtype with an ajax request

2 Dec 2010, 11:13 AM

I have a vtype inside which I make a request.

The result of that request will be the result of the vtype but I don't know how to implement that

Ext.apply(Ext.form.VTypes, {
atLeastOneYes :
function(val, field) {
var conn = new Ext.data.Connection();
url: .......,
params: ..........,
method: 'GET',
success: function(response, opts) {
var decodedResponse = Ext.util.JSON.decode(response.responseText);
vtypeResult = true or false
failure: function(response, opts) {
I want to return vtypeResult here

Thank you in advance for your answers

2 Dec 2010, 12:12 PM
Come on! you know you can't do it like that! Just reading the code tells you.

2 Dec 2010, 12:54 PM
Remember, Ajax requests are async so your code won't work. Search the forums for remotevalidator ux, should be useful to you :)

2 Dec 2010, 12:57 PM
Hi animal and thank you for your answer

Do you have an idea how I can do in another way ??

3 Dec 2010, 7:51 AM
The basex extension allows for synchronous Ajax requests, which would work in your case.

Otherwise you might query the server way ahead of time for all your vtypes and use them after they're loaded.

5 Dec 2010, 3:28 AM
Hi mschwartz and thank you for your answer,

The basex extension should do the trick. But what have I to do to include it in EXTJS 3.0 and is there any example that show how to use it ?

When I am talking about an example I am looking for an example where I can get synchronously the result of a request and use it afterwards

5 Dec 2010, 12:00 PM
You are storing up problems forcing synchronous behaviour onto an inherently asynchronous system like the browser and its IO and event system.

Mark your field valid or invalid upon return from the call.

Do not be tempted to force usage of outdated and unworkable paradigms.

Learn to read asynchronous code, and learn to design asynchronous systems.

You will have to eventually.

6 Dec 2010, 1:19 AM
Hi animal and thank you for your answer

I don't see in the API documentation how you can mark a field valid or invalid

6 Dec 2010, 1:33 AM
http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.Field&member=markInvalid ?

6 Dec 2010, 1:41 AM
Yes you can mark the field invalid but how can you mark it valid

6 Dec 2010, 1:43 AM

ps. You really should have a look at the RemoteValidator plugin (http://www.sencha.com/forum/showthread.php?19112-New-Remote-Field-Validation-Plugin).

6 Dec 2010, 2:09 AM
Hi condor and thank you for your answer. Now it is working

ps : the reason why I don't use remoteValidator plugin is that I have 2 possibilities for validation one possibility with local management and one with remote management both in the same unit (I test in the vtype which validation case I use)

6 Dec 2010, 2:41 AM
Yes you can mark the field invalid but how can you mark it valid