tags:

views:

53

answers:

3

Hello,

Is there an alternative to .load() in jQuery.

Thanks Jean

A: 

Please increase your acceptance rate. Its too low. .ajax() is an alternative. Can you state the purpose for which you want to use an alternative?

Shripad K
If I have to increase my acceptance rate, then I need solutions to all my questions. .ajax is to submit, can it be used to load a .php file, simply load
Jean
this should be in a comment
jAndy
@Jean - `.ajax` is *not* to submit, in fact the default behavior is a `GET` not a post, `$.ajax` is used, at the core, for all of these functions.
Nick Craver
Sorry but you got the concept of `.load()` itself wrong. Please read more about it in the docs. Also you will get better solutions depending on how good your acceptance rate is. Lower the rate poorer the answers.
Shripad K
@shripad lower rate could also mean the questions are good enough
Jean
+3  A: 

Yes, you can use $.ajax() directly if you need additional control over what .load() offers.

There are also other $.ajax() shorthand methods available.

Nick Craver
A: 

As has been mentioned you can use $.ajax() directly.

Here is an example of this.

function update_user_ajx(user_id){

 var data = { 
 username: $('#UsernamePost_' + user_id).val(), 
 password: $('#PasswordPost_' + user_id).val(),
 email:   $('#EmailPost_' + user_id).val(),
 accesslevel: $('#AccessLevelPost_' + user_id).val()
 };

 $.ajax({
  url: "/managesettings/updateuser/" + user_id,
  type: "POST",
  data: data,
  cache: false,
  success: function (html) {

   /* Replace Content */
   $('#UpdateUsers').html(html);

   /* Try Fade In */
   $('#UpdateUsers').fadeIn('slow'); 
  }
 });
}
DRL
You example does not show an alternative to `load()`.
Felix Kling
Nick Craver
@Nick Craver: Thanks for pointing this out, i have modified my answer to reflect this.
DRL