Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6026337
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T04:25:52+00:00 2026-05-23T04:25:52+00:00

Currently Im trying to do ajax request using jQuery Mobile. I`m trying to use

  • 0

Currently Im trying to do ajax request using jQuery Mobile. I`m trying to use example on http://www.giantflyingsaucer.com/blog/?p=2574. Yes, it works perfectly. But problems was coming when i tried to use the code inside codeigniter.

Here is my controller :

<?php
class Ajax extends CI_Controller {
    function __construct() {

    }

    function index() {
        ?>
        <!DOCTYPE html>
        <html>
            <head>
            <title>Submit a form via AJAX</title>
              <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a4/jquery.mobile-1.0a4.min.css" />
              <script src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
              <script src="http://code.jquery.com/mobile/1.0a4/jquery.mobile-1.0a4.min.js"></script>
        </head>
        <body>
            <script>
                function onSuccess(data, status)
                {
                    data = $.trim(data);
                    $("#notification").text(data);
                }

                function onError(data, status)
                {
                    // handle an error
                }        

                $(document).ready(function() {
                    $("#submit").click(function(){

                        var formData = $("#callAjaxForm").serialize();

                        $.ajax({
                            type: "POST",
                            url: "callajax",
                            cache: false,
                            data: formData,
                            success: onSuccess,
                            error: onError
                        });

                        return false;
                    });
                });
            </script>

            <!-- call ajax page -->
            <div data-role="page" id="callAjaxPage">
                <div data-role="header">
                    <h1>Call Ajax</h1>
                </div>

                <div data-role="content">
                    <form id="callAjaxForm">
                        <div data-role="fieldcontain">
                            <label for="firstName">First Name</label>
                            <input type="text" name="firstName" id="firstName" value=""  />

                            <label for="lastName">Last Name</label>
                            <input type="text" name="lastName" id="lastName" value=""  />
                            <h3 id="notification"></h3>
                            <button data-theme="b" id="submit" type="submit">Submit</button>
                        </div>
                    </form>
                </div>

                <div data-role="footer">
                    <h1>GiantFlyingSaucer</h1>
                </div>
            </div>
        </body>
        </html>
        <?php
    }

    function callajax() {
        echo "ok";
    }
}

I want to display ‘ok’ in notification. Im trying to call function callajax instead of call from callajax.php is this possible or do I need to create callajax.php?
I
ve tried to create callajax.php but it was failed.

Thank you,

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T04:25:52+00:00Added an answer on May 23, 2026 at 4:25 am

    You probably want the url to be:

     url: "ajax/callajax",
    

    As you are calling the callajax function within the controller ajax.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently trying to program my first ajax interface using Rails. The application
I'm trying to build a reusable $.ajax method for my current application but I'm
I currently trying to find a solution, how to ensure that a test fails
I'm currently trying to read in an XML file, make some minor changes (alter
I'm currently trying out db4o (the java version) and I pretty much like what
I'm currently trying to build a personal website to create a presence on the
I'm currently trying to port a SIP stack library (pjSIP) to the PSP Console
I'm currently trying to get into the Java EE development with the Spring framework.
My team is currently trying to automate the deployment of our .Net and PHP
I'm currently trying to debug a customer's issue with an FTP upload feature in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.