Created
March 29, 2011 23:51
-
-
Save wenbert/893591 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> | |
}); |
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
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.