jQuery ajax post data to aspx webpage

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.
Who is Participating?
Kyle HamiltonConnect With a Mentor Data ScientistCommented:
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

STRACAuthor Commented:
Valid solution, with a few limitations. Thanks!
Kyle HamiltonData ScientistCommented:
no prob. What limitations do you mean?
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.

All Courses

From novice to tech pro — start learning today.