This is a migrated thread and some comments may be shown as answers.

Issue with Ajax call in a Model

3 Answers 63 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
XiMnet Malaysia
Top achievements
Rank 1
XiMnet Malaysia asked on 01 Dec 2014, 10:15 AM
Hi,

Refering to http://telerik.ximnet.com.my/kendo_test/, the page will call the the function fn_mobileMS_update in model mobileMS.js (http://telerik.ximnet.com.my/kendo_test/js/mobileMS.js)

In the function fn_mobileMS_update, it will call XiMnet_JS_Tool.fn_XiMnet_ajax_JSONP which is an AJAX call.

However, I noticed via the console, the success event of the Ajax call is fired after the code in mobileMS.js -> console.log("mobileMS").
How do I make sure the code will fire only after the Ajax call is completed so that I can get the data? I already set it as async: false,

Console:
XiMnet_JS_Tool.js:58 beforeSend - fn_XiMnet_ajax_JSONP
mobileMS.js:30 mobileMS
XiMnet_JS_Tool.js:72 success - fn_XiMnet_ajax_JSONP

Thanks.

3 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 02 Dec 2014, 03:32 PM
Hello,

I am not sure how the problem you are facing is related to or affected by Kendo UI. Does the code in question work outside of the model context?

Regards,
Petyo
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
XiMnet Malaysia
Top achievements
Rank 1
answered on 03 Dec 2014, 02:53 AM
Hi  Petyo,

It works in our local development server.
However, when we upload to a staging server, it has this error.

In the staging server, the sub-domain is different:
http://telerik.ximnet.com.my/kendo_test/ calls http://xtopia_platform_d02.ximnet.com.my/api

Could this be the cause?

0
XiMnet Malaysia
Top achievements
Rank 1
answered on 03 Dec 2014, 10:04 AM
I think it is because AJAX with JSONP type cannot be synchronous when cross-domain.
I will try to find other solution,

Thanks.
Tags
MVVM
Asked by
XiMnet Malaysia
Top achievements
Rank 1
Answers by
Petyo
Telerik team
XiMnet Malaysia
Top achievements
Rank 1
Share this question
or