I Pakistani from Saudi Arabia, I want to visit Dubai for 2 days.
So I get air ticket from Saudi Arabia to Dubai. Can I get visa on arrival in Dubai or Sharja airport to stay there for 2 days?
Nationals of Pakistan are not eligible for a UAE tourist visa on arrival. You will need to obtain a visa in advance.
You can apply for your visa online. After you have booked your flight with Emirates, go to Manage your booking to apply for the visa. When you apply this way, you do not need a visa stamp on your passport.
You can also apply the traditional way, through the UAE embassy or consulate serving the area where you reside (e.g. in Riyadh or Jeddah).
If you have permanent residency in Saudi Arabia (ie, an iqama) you need to apply online at this website - as GCC permanent residents can get a visa to Dubai.
As of October, on arrival visas have been stopped in favor of the online application.