Created
July 10, 2014 03:55
-
-
Save NekoTashi/1027c30611c9e66def3d 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
# 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