onsubmit glide ajax issue
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2025 05:15 AM
Can someone help me understand why this code is not working? I'm trying to use GlideAjax in an onSubmit client script
This is not a real requirement—I just want to learn because I was asked this in an interview last time.
Also, if this question comes up in an interview, what would be the best way to answer it?
function onSubmit() {
//Type appropriate comment here, and begin script below
var a = new GlideAjax('S_i_catalog_item');
a.addParam('sysparm_name', 'get_email');
a.addParam('sysparm_name_field', g_form.getValue('user'));
a.getXML(callback);
function callback(response) {
var answer = response.responseXML.documentElement.getAttribute('answer');
g_form.setValue('onsubmit_email_user', answer);
g_form.submit();
}
return false;
}
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-14-2025 05:20 AM
@prafful garg - Glide Ajax will fail as it's asynchronous. Try to use onChange instead of onSubmit.
Thanks & Regards,
Vasanth