jQuery ajax post data to aspx webpage

Posted on 2012-08-27
Last Modified: 2012-09-03
Hello Experts,

I am building an app in xCode with phonegap. Currently I am using ajax to load data from a remote source (Display.aspx) and that is working perfect. However I want to then post data to my Input.aspx page. I have the sites whitelisted so crossdomain issues should not be there.

I also tried the code on the same server to verify it is not a crossdomain issue.

Right now the form that adds data to my database is a basic page with text inputs.

Now I have a third page (which eventually will be an iOS app) that I am trying to post from. Can I not just use ajax to submit directly to the Input.aspx page, or do I have to have some kind of web service?

I think I need a clear example of how ajax can submit data to a remote website (remember crossdomain should not be an issue as it is an app).

I think I don't get how the aspx page should be built? Does it need specific code for the ajax or can it just be a generic page with a form that submits?

Any help is greatly appreciated.
Question by:STRAC
    LVL 25

    Accepted Solution

    If i understand correctly, you want the input from one page to poulate a form on another page?

    You can use javascript by passing the values via a query string and and reading them in using javascript on the rusulting page.

    Your form on page 1 uses GET. This will pass the name field to the resultsPage.html
    <form name="myForm" id="myForm" method="GET" action="resultsPage.html">
    <input type="text" name="first_name"/>
    <input type="submit" value="Click here to continue" class="submit">

    Open in new window

    On the resultPage.html you will need a script that reads the url. The form field names must match the form from the previous page:
    <form name="myForm">
    <input type="text" name="first_name"/>
    <script type="text/javascript" language="JavaScript">
        <!-- Copyright 2006 Bontrager Connection, LLC
        function FillForm() {
            // Specify form's name between the quotes on next line.
            var FormName = "myForm";
            var questionlocation = location.href.indexOf('?');
            if(questionlocation < 0) { return; }
            var q = location.href.substr(questionlocation + 1);
            var list = q.split('&');
            for(var i = 0; i < list.length; i++) {
                var kv = list[i].split('=');
                if(! eval('document.'+FormName+'.'+kv[0])) { continue; }
                kv[1] = unescape(kv[1]);
                if(kv[1].indexOf('"') > -1) {
                    var re = /"/g;
                    kv[1] = kv[1].replace(re,'\\"');

    Open in new window


    Author Closing Comment

    Valid solution, with a few limitations. Thanks!
    LVL 25

    Expert Comment

    by:Kyle Hamilton
    no prob. What limitations do you mean?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
    Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now