Hello ,
I am working on quick project , listing search results from bing and my goal is user can save searches they perform . however i manage to list the search results in the template , and right now want to save the result items to the database using AJAX ! well this is my first attempt with ajax ( jquery ) and django !
template
{% for result in results %}<div class="resimgb">
<a href="{{ result.MediaUrl }}"><img src="{{ result.Thumbnail.Url }}" /></a>
<br />
<input type="text" value="{{ result.MediaUrl }}" id="#urlink">
<input type="submit" id="#savethis" name="add"></span><a herf="#" id="">save</a></div>{% endfor %}
JS :
<script type="text/javascript">
$( document ).ready( function() {
$( '#savethis' ).click( function() { data =
$( '#urlink' ).val(); $.get("/save/", function(data) {
alert(data);
});
});
});
</script>
-
I don't write the view , cause am stuck at there actually ! well its going complex for me from here , as am little confused in
- How to save the data to my model ?
- How to send a response into the template to confirm saving the result ?
- as am a newbie to jquery , i know this is very wrong to use id inside a loop , can anyone suggests how to fix this issue ?
There are many tutorials about Django / jQuery , but most of them i came through are mainly superficial enough to leave me with open questions as well !!