0

I'm new to Web development, usually I'm used to software development but studying web development confuses me a lot. please forgive my newbie question

What I'm trying to do is test every domain that is inside my array(dMains) so that every domain can be checked by the script since the goal is to make it work for every domain. Hope u guys can help me thanks a lot.

<!DOCTYPE html>
<html>
    <body onload="loopdMains()">
        <script>history.pushState('', '', '/')</script>
        <script>
            var dMains=["my.firstdomain.com","my.seconddomain.com"];

            function loopdMains()

            {
                for(var i=0;i<dMains.length;i++)
                {

                <form action=(i) method="POST">
                <input type="hidden" name="type" value="excl" />
                <input type="hidden" name="action" value="update" />
                <input type="hidden" name="period" value="1" />

                }
            }

        </script>
    </body>
</html> 
7
  • You cannot directly write HTML in JavaScript code. See this post. Create a string and then append it to the DOM. Commented May 7, 2018 at 3:13
  • What are you trying to achieve ? Commented May 7, 2018 at 3:15
  • You can change the form action using JavaScript like document.querySelector('form').action = dMains[i]. If you're trying to test an API call on multiple domains, I'd suggest using a better tool like Postman with multiple environments. Commented May 7, 2018 at 3:15
  • @31piy ok thank u I'll study it. Commented May 7, 2018 at 3:19
  • @PrajvalM to loop every single domain in "form action". E.G. First loop <form action="my.firstdomain.com"> together with 3 lines of code below. Second loop <form action="myseconddomain.com> together with 3 lines of code below Commented May 7, 2018 at 3:20

1 Answer 1

1

If you want to just send post requests and check for the response use xhhtp, jquery or axios to do the post request. Attach a eventListener to your window object and trigger it when you have a response. You have option to set the url in these Eg.

//JQuery
$.ajax({ 
  type: "POST",
  url: url,
  data: data,
  success: success,
  dataType: dataType
}

//axios
axios.post(url, callbackFunction);

in your loop set url parameter and in your call back once you get response dispatch the event. Listen to 6 of such and after that your are done.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.