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的更多相关文章

  1. .NET invoke NetSuite Restlet

    Please indicate the source if you need to repost. Restlet allows programmers to use the http request ...

  2. 手机新闻网站,手持移动新闻,手机报client,jQuery Mobile手机新闻网站,手机新闻网站demo,新闻阅读器开发

    我们坐在地铁.经常拿出新浪手机查看新闻.腾讯新闻,或者看新闻,等刷微信功能.你有没有想过如何实现这些目标. 移动互联网.更活泼. 由于HTML5未来,jQuery Moblie未来. 今天我用jqm的 ...

  3. 手机新闻网站,掌上移动新闻,手机报client,jQuery Mobile手机新闻网站,手机新闻网站demo,新闻阅读器开发

    我们坐在地铁,经常来查看新浪手机新闻,腾讯新闻.或者刷微信看新闻更多功能.你有没有想过如何实现这些目标.移动互联网,更活泼. 因为HTML5到,jQuery Moblie到.今天我用jqm为了给你一个 ...

  4. JQuery invoke remote webservice

    Sending the Access-Control-Allow-Origin header allows basic cross-origin access, but calling ASP.NET ...

  5. Writing Your Own jQuery Plugins

    Setting Up <script src="js/jquery-1.9.1.min.js"></script> <script src=" ...

  6. 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 ...

  7. 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 ...

  8. 【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 ...

  9. MSCRM 通过Ajax调用WCF服务

    Call WCF Service from Dynamics CRM using AJAX A couple of days back, I had one of my ex-colleagues c ...

随机推荐

  1. jQuery.Data源码

    jQuery.data的是jQuery的数据缓存系统.它的主要作用就是为普通对象或者DOM元素添加数据. 1 内部存储原理 这个原理很简单,原本要添加在DOM元素本身的数据,现在被集中的存储在cach ...

  2. JS兼容所有浏览器的一段加入收藏代码,设置为首页

    <script language="javascript" type="text/javascript"> function addfavorite ...

  3. fastcgi配置

    fastcgi配置 我们这里说的fastcgi配置专指nginx对fastcgi的配置,fastcgi本身的配置介绍在fastcgi 安装文中有说明. nginx的fastcgi模块提供的命令 fas ...

  4. Web API应用支持HTTPS的经验总结

    在我前面介绍的WebAPI文章里面,介绍了WebAPI的架构设计方面的内容,其中提出了现在流行的WebAPI优先的路线,这种也是我们开发多应用(APP.微信.微网站.商城.以及Winform等方面的整 ...

  5. PHP访问MySql数据库介绍

    在网站后台,经常要与数据库打交道.本文介绍如何使用XAMPP来管理MySql数据库及如何用PHP来访问MySql数据库. 一.使用XAMPP来管理MySql数据库 首先使用XAMPP打开MySql的管 ...

  6. .NET vs2010中使用IrisSkin2.dll轻松实现winForm窗体换肤功能

    IrisSkin2.dll是一款很不错的免费皮肤控件,利用它可以轻松的实现winForm窗体换肤! 网上很多朋友说在VS2010中不能使用IrisSkin2.dll,我这里提供一个取巧的办法. Iri ...

  7. jquery可见性选择器(综合)

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. 用dos开启apache问题说明

  9. 建立MySQL的ODBC

    1. 进入控制面板->管理工具->数据源(ODBC): 2. 点击添加,数据源驱动程序选择MySQL ODBC 5.1 Driver: 3. 弹出MySQL Connecotor/ODBC ...

  10. 【Java每日一题】20161104

    package Nov2016; public class Ques1104 { private String num; public void setNum(String num){ num = n ...