How to get jQuery AJAX form to display results on same page, not ASP processing page

Hello,

I'm an extreme jQuery newbie. I'm using jQuery and the forms plug-in to process form input and I want to display the results on the same page. I borrowed some code from the forms plug-in example page (http://www.malsup.com/jquery/form/#code-samples) to play around so I could learn how to do this.

I currently have to do server-side processing with ASP. When I submit the form, the results are correct, but they appear on the ASP page, not on the HTML form page. What do I need to change so this form will work?

Here's the code from my HTML form page:

<script language="javascript">

$(document).ready(function() {
    var options = {
        target:        '#output1',   // target element(s) to be updated with server response
        success:       showResponse  // post-submit callback
    };
 
    // bind form using 'ajaxForm'
    $('#myForm1').ajaxForm(options);
});
 
// post-submit callback
function showResponse(responseText, statusText)  {
    // for normal html responses, the first argument to the success callback
    // is the XMLHttpRequest object's responseText property
 
    // if the ajaxForm method was passed an Options Object with the dataType
    // property set to 'xml' then the first argument to the success callback
    // is the XMLHttpRequest object's responseXML property
 
    // if the ajaxForm method was passed an Options Object with the dataType
    // property set to 'json' then the first argument to the success callback
    // is the json data object returned by the server
 
    alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
        '\n\nThe output div should have already been updated with the responseText.');
}

</script>
</head>

<body>

<form id="myForm1" action="/fsstest/comm/Scripts/acct_ownership.asp" method="post"><div>
                        <input type="hidden" name="Hidden" value="hiddenValue" />
                        <table>
                        <tr><td>Zip:</td><td><input name="zip" type="text" /></td></tr>
                        </table>
                        <input type="reset"   name="resetButton " value="Reset" />

                        <input type="submit"  name="submitButton" value="Submit1" />
                </div></form>
                <h1>Output Div (#output1):</h1>
                <div id="output1">AJAX response will replace this content.</div>
            </div>

Here's the code from my ASP page:

Dim pr_zips
Dim search_zip
Dim search_results
 
Set pr_zips=Server.CreateObject("Microsoft.XMLDOM")
pr_zips.async=false

search_zip=request.form("zip")

pr_zips.load(Server.MapPath("/fsstest/comm/db/fy08h2_pr.xml"))

if pr_zips.parseError.errorcode = 0 then
Set search_results = pr_zips.selectSingleNode("/assignments/tty/zips/zip[@id='"& search_zip &"']")

response.write "You searched for " & search_results.text
else
    response.write "An Error Occurred: " & cstr(pr_zips.parseError.errorcode)
end if
%>

Thanks in advance--

Kathryn
KathrynGZAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
are you actually linking/importing the jQuery library? IF you look at the source code of that example they are importing:
http://www.malsup.com/jquery/jquery-1.2.6.js
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KathrynGZAuthor Commented:
ARRGH!!  <shakes head> That was exactly the problem! I'd linked to the jQuery .js file in my real form, but not in the test one I was playing around with.

Well, at least this question will make people smile when they read it, and it might actually help someone else who missed the obvious :)

Thanks again!

Kathryn
0
hieloCommented:
>>ARRGH!!
It happens more often than you might think

>>Thanks again!
you are welcome!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.