Skip to content

Instantly share code, notes, and snippets.

@wenbert
Created March 29, 2011 23:51
Show Gist options
  • Save wenbert/893591 to your computer and use it in GitHub Desktop.
Save wenbert/893591 to your computer and use it in GitHub Desktop.
<div id="container">
<input type="hidden" id="var" value="wenbert"/>
<input type="button" id="thebutton" value="Click"/>
</div>
<script type="text/javascript">
$(document).ready(function() {
<script type="text/javascript">
$(document).ready(function() {
$("#thebutton").click(function(){
call_ajax1();
call_ajax2();
});
function call_ajax1(){
$.post("/books/action1/",
{
csrfmiddlewaretoken: $("input[name='csrfmiddlewaretoken']").val(),
var: $("#var").val(),
},
function(data){
if(data['success']){
// show results to DOM here
} else {
console.log("error");
return false;
}
},
"json"
);
}
function call_ajax2(){
$.post("/books/action2/",
{
csrfmiddlewaretoken: $("input[name='csrfmiddlewaretoken']").val(),
var: $("#var").val(),
},
function(data){
if(data['success']){
// show results to DOM here
} else {
console.log("error");
return false;
}
},
"json"
);
}
});
</script>
});
@wenbert
Copy link
Author

wenbert commented Mar 29, 2011

lets say sa call_ajax1() ang return i-output nimo sa "div_a" then ang return sa call_ajax2() imu i-out sa "div_zzz"....ga-libog kay imu g-huna2x ra imu g-over complicate...

if dili gani madala ani, tell me unsa imu gusto mahitabo...

@john2x
Copy link

john2x commented Mar 30, 2011

What if both $.post()s point to the same url? /books/search/..

Ako plano kay ig-search sa title/author, mag search ko sa local database for the book using Book.objects.filter(...) in the view and at the same time mg-search pd ko sa Amazon. Kay mas dali man m-kuha ang naa sa local database, para m-una og display nya m-apas lng Amazon results.

@wenbert
Copy link
Author

wenbert commented Apr 2, 2011

pwede raman na sa usa ka view and then ang ireturn nimo from localdb sulod nimo ug usa ka list then ang i-return nimo gkan sa amazon sulod pd nimo ug usa ka list.

just search the localdb first aron mas kusog then ang amazon dayon sunod...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment