var Box = function(){ this.parm = {name:"rajakvk",year:2010}; Box.prototype.jspCall = function() { $.ajax({ type: "post", url: "some url", success: this.exeSuccess, error: this.exeError, complete: this.exeComplete }); } this.exeSuccess = function(){ alert(this.parm.name); } }
I'm not getting Box object inside exeSuccess method. How to pass Box object inside exeSuccess method?
You can store your promise, you can pass it around, you can use it as an argument in function calls and you can return it from functions, but when you finally want to use your data that is returned by the AJAX call, you have to do it like this: promise. success(function (data) { alert(data); });
context : An object to use as the context ( this ) of all Ajax-related callbacks. converters : An object containing dataType-to-dataType converters. crossDomain : Set this property to true to force a cross-domain request (such as JSONP) on the same domain.
So, add a success option to your partial-view ajax request and then get the response and render it in the div you want the partial-view to be visible as: success: function(response){if(response!= null) $('<yourDivInWhich you want to render the partial view>'). html(response)} .
success : A callback function that is executed if the request succeeds.it takes as an argument the returned data. It is also passed the text status of the response. dataType : The type of data expected from the server. The default is Intelligent Guess (xml, json, script, text, html).
Use the context
option, like this:
$.ajax({ context: this, type: "post", url: "some url", success: this.exeSuccess, error: this.exeError, complete: this.exeComplete });
The context option determines what context the callback is called with...so it determines what this
refers to inside that function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With