Client JQuery invoke NetSuite Suitelet
Please indicate the source if you need to repost.
Client jQuery could initialize a cross-domain request. Certainly, jQuery could initialize a NetSuite request.
jQuery code (client):
function clickMe() {
try {
var myUrl = your_http_url;
$.ajax({
url: myUrl,
dataType: 'jsonp',
data: { "myName1": 2345 },
jsonp: 'callback',
jsonpCallback: "asyncButton",
success: function (result) {
for (var i in result) {
alert(i + " : " + result[i]); //Print response result
}
},
error: function (result1) { alert(2) },
timeout: 3000
});
}
catch (ex) {
alert(ex);
}
}
Client jQuery
Suitelet code (server):
function asyncButton(request, response) {
var x = request.getParameter('myName1');
var y = request.getParameter('myName2');
nlapiLogExecution('debug','test',x+', '+y);
response.write('asyncButton({"myName":"DanielCai"})');
}
NetSuite Suietlet
Note: Suitelet MUST check the 'Available without login' option.
Howerver, this kind of request doesn't have any credentials, which means it's an insecure request.
Restlet seems an optiop. I tried with Restlet, it didn't work out.
I guess the reason why it failed:
Cross-domain request MUST set 'Access-Control-Allow-Origin' in the server headers.
And Restlet doesn't allow coder to set the headers, so doesn't Suitelet.
I think the 'Available without login' option set the headers for us. :)
That's why Suitelet works for client jQuery
// Allow all the other parties to access.
header('Access-Control-Allow-Origin:*');
// Response type
header('Access-Control-Allow-Methods:POST');
// Response headers
header('Access-Control-Allow-Headers:x-requested-with,content-type');
PHP Server
Client JQuery invoke NetSuite Suitelet的更多相关文章
- .NET invoke NetSuite Restlet
Please indicate the source if you need to repost. Restlet allows programmers to use the http request ...
- 手机新闻网站,手持移动新闻,手机报client,jQuery Mobile手机新闻网站,手机新闻网站demo,新闻阅读器开发
我们坐在地铁.经常拿出新浪手机查看新闻.腾讯新闻,或者看新闻,等刷微信功能.你有没有想过如何实现这些目标. 移动互联网.更活泼. 由于HTML5未来,jQuery Moblie未来. 今天我用jqm的 ...
- 手机新闻网站,掌上移动新闻,手机报client,jQuery Mobile手机新闻网站,手机新闻网站demo,新闻阅读器开发
我们坐在地铁,经常来查看新浪手机新闻,腾讯新闻.或者刷微信看新闻更多功能.你有没有想过如何实现这些目标.移动互联网,更活泼. 因为HTML5到,jQuery Moblie到.今天我用jqm为了给你一个 ...
- JQuery invoke remote webservice
Sending the Access-Control-Allow-Origin header allows basic cross-origin access, but calling ASP.NET ...
- Writing Your Own jQuery Plugins
Setting Up <script src="js/jquery-1.9.1.min.js"></script> <script src=" ...
- org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Server returned error code = 404 for URI.. Check server logs for details
严重: Servlet.service() for servlet jsp threw exceptionorg.codehaus.xfire.XFireRuntimeException: Could ...
- Learning WCF Chapter1 Generating a Service and Client Proxy
In the previous lab,you created a service and client from scratch without leveraging the tools avail ...
- 【ASP.NET Web API教程】1.1 第一个ASP.NET Web API
Your First ASP.NET Web API (C#)第一个ASP.NET Web API(C#) By Mike Wasson|January 21, 2012作者:Mike Wasson ...
- MSCRM 通过Ajax调用WCF服务
Call WCF Service from Dynamics CRM using AJAX A couple of days back, I had one of my ex-colleagues c ...
随机推荐
- Nodejs学习笔记(一)——初识Nodejs
前言:目前工作的分内之事相对较为单一,希望可以通过工作之余的时间给自己充充电,只是没有一个学伴或大神带,只能说是摸索着前进.起初准备好好研究下Spring这个框架,下载了源码,结合书籍准备一探究竟,看 ...
- PetaPojo —— JAVA版的PetaPoco
背景 由于工作的一些原因,需要从C#转成JAVA.之前PetaPoco用得真是非常舒服,在学习JAVA的过程中熟悉了一下JAVA的数据组件: MyBatis 非常流行,代码生成也很成熟,性能也很好.但 ...
- ssl证书生成:cer&jks文件生成摘录
一.生成.jks文件 1.keystore的生成: 分阶段生成: keytool -genkey -alias yushan(别名) -keypass yushan(别名密码) -keyalg ...
- 【转】ASP.NET"正在中止线程"错误原因
最近做的系统中老出现的一些问题不太明白,在使用 Response.End.Response.Redirect 或 Server.Transfer 时出现 ThreadAbortException , ...
- Sql去重语句
海量数据(百万以上),其中有些全部字段都相同,有些部分字段相同,怎样高效去除重复? 如果要删除手机(mobilePhone),电话(officePhone),邮件(email)同时都相同的数据,以前一 ...
- 插入排序---希尔插入排序算法(Javascript版)
取一个小于n的整数作为第一个增量,把序列分组.所有距离为增量的倍数的元素放在同一个组中.先在各组内进行直接插入排序:然后,取第二个增量(第二个<第一个)重复上述的分组和排序,直至所取的增量=1, ...
- 【SQL】分享表值函数FMakeRows,用于生成行
------------更新:201501071730------------ 评论中又有一位[笑东风]兄给出改善建议,在此先感谢他.原理是借助行数较多的一个系统视图sys.all_columns与自 ...
- FAILED BINDER TRANSACTION
最近开发Widget,要在Widget上显示图片,出现了FAILED BINDER TRANSACTION错误,后来才发现是因为图片太大了.Widget使用的是RemoteViews,而Intent传 ...
- cookies
Cookie[] cookies=request.getCookies(); for(Cookie c:cookies) out.println(c.getValue()+" ") ...
- MySQL Error Handling in Stored Procedures 2
Summary: this tutorial shows you how to use MySQL handler to handle exceptions or errors encountered ...