Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
1199 Переглядів

Hello, I'm including script inside my form view to call an API when the form is loaded. But, I need to pass a field value into that script. Can you help?

For example, I have the field "product_code" and need to pass its value into the following script:

var  Http  =  new  XMLHttpRequest ();
var  url  =  'https: // OURAPIURL /' ;

var  productdata  =  {
    "product_code""1223"
}

Http . open ( "POST"url );
Http . setRequestHeader ( "Content-Type" , "Application / JSON" );
Http . send ( JSON . stringify ( ProductData ));
Http . onreadystatechange = function () {
    if ( this . readyState == 4  &&  this . status == 200 ) {
        console . log ( Http . responseText )
    }
}


I'd like the value "1223" to be the value of the the "product_code" from the record.

Аватар
Відмінити