Skip to content

Instantly share code, notes, and snippets.

@NekoTashi
Created July 10, 2014 03:55
Show Gist options
  • Save NekoTashi/1027c30611c9e66def3d to your computer and use it in GitHub Desktop.
Save NekoTashi/1027c30611c9e66def3d to your computer and use it in GitHub Desktop.
# Ajax usando JQuery
$.ajax({
url: "http://miURL.com/mi_vista_django/",
type: 'GET', // POST, DELETE, PUT
success: function(data) {
console.log(data); // Print data
},
error: function() {
// Do something
}
});
# URLs
from django.conf.urls import patterns
urlpatterns = patterns('',
(r'^mi_vista_django$', "mi_app.views.mi_vista_django"),
)
# Views
import json
from django.http import HttpResponse
def ajax(request):
data = {}
data['Contenido'] = 'Hola Mundo'
return HttpResponse(json.dumps(data), content_type = "application/json")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment