0

first of all forgive me my poor english it's not my lang.

I am trying to work with ajax as follows:

I created a webservice and a web page that calls to a method in the webservice. I am trying to call the service like this:

<button onclick="run()" formmethod="post">Sample</button>

The problem is that if this button is inside the form, it doesn't work because it posts back. If the button is outside of the form it works.

How can I put this button inside the form and still have it call the web service?

1 Answer 1

1

I am thinking the problem is the button initalizes a submit before the service is called.

What I would suggest would be to use an input button and handle the click event:

<input type='button' onclick='CallService();' value='Sample' id='btnSample' />

in your script have:

function CallService(){
    {ServiceName}.run({parameter},CallComplete);
}

function CallComplete(){
    document.form.submit();
}

I would say do it this way so that you know your service is being called before the form is submitted.

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.