Last active
August 29, 2015 14:00
-
-
Save imranismail/11111515 to your computer and use it in GitHub Desktop.
Laravel + Jquery Ajax .post
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
//Javascript | |
$(function() | |
{ | |
var BASE_URL = window.location.protocol + '//' + window.location.host; | |
$("#buttonselector").click(function() { | |
var data = { | |
'inputelementname' : $('#inputelementselector').val(), | |
}; | |
$.post( BASE_URL + "/apply/ajax", data, function(response) { | |
console.log('Ajax loading successful'); | |
console.log(response); | |
}) | |
.fail(function() { | |
console.log('Ajax loading failed'); | |
}) | |
}); | |
}); | |
// Laravel Routes (you can use controller but this is just for testing) | |
Route::post('/apply/ajax', function() | |
{ | |
$data = Input::get('inputelementname'); | |
return $data | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment