0

i used jQuery with Ajax By this code it works fine

$.ajax({
                type : 'POST',
                url: 'http://localhost/msite/index.php/site/ajax',
                data : catdata,
                success : function (msg){
                    $('body').html(msg);
                }
                });

but i want to show the ajax-loading gif while fetching that information from database?

And , is that way secure Or i have to add some security to it?

4
  • I don't understand what you mean by secure? You're posting over HTTP, so everything you send is in plain text, so it isn't secure. Commented Apr 18, 2011 at 21:44
  • @James Allen : So how can i make that secure Commented Apr 18, 2011 at 21:49
  • You need to use HTTPS, which will require the purchase of a certificate. When you contact a website using HTTPS rather than HTTP, everything sent is encrypted in both directions. Here's a link with further information: HTTP Secure. Hope that helps Commented Apr 18, 2011 at 21:59
  • @James Allen : Thank u 4 help Commented Apr 18, 2011 at 22:02

3 Answers 3

1
$('body').html("<img src='spin.gif' />").fadeIn(100, function () {
   $.ajax({
    type: 'POST',
    url: 'http://localhost/msite/index.php/site/ajax',
    data: catdata,
    success: function (msg) {
        $('body').html(msg);
      }
    });
});
Sign up to request clarification or add additional context in comments.

Comments

0

If you make your database query synchronous on the server then your Ajax will be spinning as long as the request is being processes, including a database query and server request/response roundtrip.

Comments

0

I believe you have to do this yourself within the jQuery. Create a hidden image on the page, call .show() just before calling the ajax command and be sure to call .hide() inside the complete event...

complete: function () {
    $("#ticker").hide();
}

You can download a suitable image from ajaxload.info.

2 Comments

How can i create a hidden image!
To be honest, I would use Shyju's solution as it's neater than mine, but here's the answer to your question: <img src='spin.gif' style='display:none;' />

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.